#2
Să se scrie un program care citeşte de la tastatură un şir de numere naturale şi determină suma lor.
| Problema | suma_n | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64911252 | Utilizator | |
| Fișier | suma_n.cpp | Dimensiune | 184 B |
| Data încărcării | 11 Iunie 2026, 22:28 | Scor/rezultat | Eroare de compilare |
suma_n.cpp: In function ‘int main()’: suma_n.cpp:6:24: warning: for increment expression has no effect [-Wunused-value] 6 | for(int x=1;1<=n;x+s;) | ~^~ suma_n.cpp:6:26: error: expected ‘)’ before ‘;’ token 6 | for(int x=1;1<=n;x+s;) | ~ ^ | ) suma_n.cpp:6:6: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 6 | for(int x=1;1<=n;x+s;) | ^~~ suma_n.cpp:6:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 6 | for(int x=1;1<=n;x+s;) | ^ suma_n.cpp:6:27: error: expected primary-expression before ‘)’ token suma_n.cpp:10:3: warning: statement has no effect [-Wunused-value] 10 | s==x*n; | ~^~~~~ suma_n.cpp: At global scope: suma_n.cpp:12:2: error: expected unqualified-id before ‘return’ 12 | }return 0; | ^~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema suma_n 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ă.