#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 | #64884786 | Utilizator | |
| Fișier | suma_n.cpp | Dimensiune | 205 B |
| Data încărcării | 09 Iunie 2026, 13:59 | Scor/rezultat | Eroare de compilare |
suma_n.cpp:1:10: error: #include expects "FILENAME" or <FILENAME> 1 | #include <iostream> | ^ suma_n.cpp: In function ‘int main()’: suma_n.cpp:8:1: error: ‘cin’ was not declared in this scope 8 | cin>>n; | ^~~ suma_n.cpp:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? +++ |+#include <iostream> 1 | #include <iostream> suma_n.cpp:8:5: error: ‘gt’ was not declared in this scope 8 | cin>>n; | ^~ suma_n.cpp:8:12: warning: statement has no effect [-Wunused-value] 8 | cin>>n; | ^ suma_n.cpp:9:12: error: ‘lt’ was not declared in this scope 9 | for(i=1; i<=n; i++) { | ^~ suma_n.cpp:9:15: error: expected primary-expression before ‘=’ token 9 | for(i=1; i<=n; i++) { | ^ suma_n.cpp:9:17: error: expected ‘)’ before ‘;’ token 9 | for(i=1; i<=n; i++) { | ~ ^ | ) suma_n.cpp:9:1: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 9 | for(i=1; i<=n; i++) { | ^~~ suma_n.cpp:9:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 9 | for(i=1; i<=n; i++) { | ^ suma_n.cpp:9:22: error: expected ‘;’ before ‘)’ token 9 | for(i=1; i<=n; i++) { | ^ | ; suma_n.cpp:13:1: error: ‘cout’ was not declared in this scope 13 | cout<<S<<" "; | ^~~~ suma_n.cpp:13:1: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? suma_n.cpp:13:6: error: ‘lt’ was not declared in this scope 13 | cout<<S<<" "; | ^~ suma_n.cpp:13:23: error: ‘quot’ was not declared in this scope 13 | cout<<S<<" "; | ^~~~ suma_n.cpp:6:14: warning: unused variable ‘x’ [-Wunused-variable] 6 | int n, i, S, x; | ^
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ă.