#4856
Se consideră un șir x cu n elemente numere întregi, ordonate crescător, și un număr întreg y. Scrieți un program care citește numerele y, n și șirul x, apoi verifică, aplicând algoritmul de căutare binară, dacă y apare în șirul x.
Folclorul informatic
| Problema | cb_0 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #63294148 | Utilizator | |
| Fișier | cb_0.cpp | Dimensiune | 415 B |
| Data încărcării | 25 Februarie 2026, 10:44 | Scor/rezultat | Eroare de compilare |
cb_0.cpp: In function 'int main()': cb_0.cpp:4:5: error: expected unqualified-id before ',' token {int,v[100] i,n,x,y,dr,mij,st,gasit; ^ cb_0.cpp:4:13: error: expected initializer before 'i' {int,v[100] i,n,x,y,dr,mij,st,gasit; ^ cb_0.cpp:5:6: error: 'i' was not declared in this scope for(i=1; i<=n; i++) ^ cb_0.cpp:5:14: error: 'n' was not declared in this scope for(i=1; i<=n; i++) ^ cb_0.cpp:6:8: error: 'v' was not declared in this scope {cin>>v[i]; st=0; dr=n-1;} ^ cb_0.cpp:6:14: error: 'st' was not declared in this scope {cin>>v[i]; st=0; dr=n-1;} ^ cb_0.cpp:6:20: error: 'dr' was not declared in this scope {cin>>v[i]; st=0; dr=n-1;} ^ cb_0.cpp:7:9: error: 'st' was not declared in this scope while(st<=dr) ^ cb_0.cpp:7:13: error: 'dr' was not declared in this scope while(st<=dr) ^ cb_0.cpp:8:4: error: 'mij' was not declared in this scope {mij=(st+dr)/2; ^ cb_0.cpp:9:7: error: 'v' was not declared in this scope if(v[mij]==y) ^ cb_0.cpp:9:15: error: 'y' was not declared in this scope if(v[mij]==y) ^ cb_0.cpp:10:7: error: 'gasit' was not declared in this scope gasit=1; ^ cb_0.cpp:15:19: error: 'x' was not declared in this scope if(v[mij]<x) ^ cb_0.cpp:17:8: error: 'gasit' was not declared in this scope if(gasit==1) ^ cb_0.cpp:18:26: error: 'v' was not declared in this scope cout<<"Da"<<" "<<v[mij]; ^ cb_0.cpp:18:28: error: 'mij' was not declared in this scope cout<<"Da"<<" "<<v[mij]; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema cb_0 face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.