#74
Scrieți definiția completă a unui subprogram C++ nr_prim care primește prin singurul său parametru, n, un număr natural cu cel mult 9 cifre și returnează cel mai mic număr prim, strict mai mare decât n.
Variante Bacalaureat 2009
| Problema | FUrmatorulPrim | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64724115 | Utilizator | |
| Fișier | furmatorulprim.cpp | Dimensiune | 267 B |
| Data încărcării | 26 Mai 2026, 10:07 | Scor/rezultat | Eroare de compilare |
furmatorulprim.cpp: In function ‘int nr_prim(int)’: furmatorulprim.cpp:11:14: warning: unused variable ‘OK’ [-Wunused-variable] 11 | bool OK=1; | ^~ furmatorulprim.cpp:13:13: error: ‘d’ was not declared in this scope 13 | for(d=3;d*d<=i;d+=2) | ^ furmatorulprim.cpp:13:22: error: ‘i’ was not declared in this scope 13 | for(d=3;d*d<=i;d+=2) | ^ furmatorulprim.cpp:15:13: error: ‘OK’ was not declared in this scope 15 | OK=0; | ^~ furmatorulprim.cpp:13:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 13 | for(d=3;d*d<=i;d+=2) | ^~~ furmatorulprim.cpp:16:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 16 | if(OK==1) | ^~ furmatorulprim.cpp:16:16: error: ‘OK’ was not declared in this scope 16 | if(OK==1) | ^~ furmatorulprim.cpp:17:20: error: ‘i’ was not declared in this scope 17 | return i; | ^ furmatorulprim.cpp:21:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 21 | int main(){ | ^~ furmatorulprim.cpp:21:9: note: remove parentheses to default-initialize a variable 21 | int main(){ | ^~ | -- furmatorulprim.cpp:21:9: note: or replace parentheses with braces to value-initialize a variable furmatorulprim.cpp:21:11: error: a function-definition is not allowed here before ‘{’ token 21 | int main(){ | ^ furmatorulprim.cpp:28:2: error: expected ‘}’ at end of input 28 | } | ^ furmatorulprim.cpp:5:1: note: to match this ‘{’ 5 | { | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FUrmatorulPrim face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.