#506
Se dă un şir cu n elemente, numere naturale. Să se verifice dacă în șir există elemente prime.
| Problema | ExistaPrime | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #65001670 | Utilizator | |
| Fișier | existaprime.cpp | Dimensiune | 447 B |
| Data încărcării | 10 Iulie 2026, 11:18 | Scor/rezultat | Eroare de compilare |
existaprime.cpp: In function ‘int main()’: existaprime.cpp:7:14: warning: right operand of comma operator has no effect [-Wunused-value] 7 | for(i=0,i<n,i++;) | ~^~ existaprime.cpp:7:21: error: expected primary-expression before ‘)’ token 7 | for(i=0,i<n,i++;) | ^ existaprime.cpp:7:21: error: expected ‘;’ before ‘)’ token 7 | for(i=0,i<n,i++;) | ^ | ; existaprime.cpp:9:14: warning: right operand of comma operator has no effect [-Wunused-value] 9 | for(i=0,i<n,i++;) | ~^~ existaprime.cpp:9:21: error: expected primary-expression before ‘)’ token 9 | for(i=0,i<n,i++;) | ^ existaprime.cpp:9:21: error: expected ‘;’ before ‘)’ token 9 | for(i=0,i<n,i++;) | ^ | ; existaprime.cpp:11:10: warning: statement has no effect [-Wunused-value] 11 | x>a[i]; | ~^~~~~ existaprime.cpp:12:12: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 12 | if(x<2&&x>2//x%2==0); | ^ existaprime.cpp:12:20: error: expected ‘;’ before ‘ok’ 12 | if(x<2&&x>2//x%2==0); | ^ | ; 13 | ok=0; | ~~ existaprime.cpp:12:15: warning: statement has no effect [-Wunused-value] 12 | if(x<2&&x>2//x%2==0); | ~~~^~~~~ existaprime.cpp:15:9: error: expected primary-expression before ‘for’ 15 | for(d=3,d+d<x,d+=2); | ^~~ existaprime.cpp:13:17: error: expected ‘)’ before ‘for’ 13 | ok=0; | ^ | ) 14 | 15 | for(d=3,d+d<x,d+=2); | ~~~ existaprime.cpp:12:11: note: to match this ‘(’ 12 | if(x<2&&x>2//x%2==0); | ^ existaprime.cpp:12:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 12 | if(x<2&&x>2//x%2==0); | ^~ existaprime.cpp:16:12: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 16 | if(x%2==0); | ^~ existaprime.cpp:20:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 20 | if(ok==1); | ^~ existaprime.cpp:21:12: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 21 | cout<<"DA"; | ^~~~ existaprime.cpp:22:5: error: ‘else’ without a previous ‘if’ 22 | else | ^~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema ExistaPrime 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ă.