#338
Să se scrie un program care citește numărul natural n
și determină suma S=1
1
+2
2
+ ... + n
n
.
Problema | Expresie5 | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58397407 | Utilizator | |
Fișier | expresie5.cpp | Dimensiune | 273 B |
Data încărcării | 01 Iunie 2025, 16:58 | Scor / rezultat | Eroare de compilare |
expresie5.cpp: In function 'int main()': expresie5.cpp:7:17: error: two or more data types in declaration of 'i' float float i,n,s=0,x,y; ^ expresie5.cpp:7:19: error: two or more data types in declaration of 'n' float float i,n,s=0,x,y; ^ expresie5.cpp:7:21: error: two or more data types in declaration of 's' float float i,n,s=0,x,y; ^ expresie5.cpp:7:25: error: two or more data types in declaration of 'x' float float i,n,s=0,x,y; ^ expresie5.cpp:7:27: error: two or more data types in declaration of 'y' float float i,n,s=0,x,y; ^ expresie5.cpp:8:10: error: 'n' was not declared in this scope cin>>n; ^ expresie5.cpp:9:10: error: 'i' was not declared in this scope for (i=1;i<=n;i++) ^ expresie5.cpp:11:9: error: 'x' was not declared in this scope x=1; ^ expresie5.cpp:12:14: error: 'y' was not declared in this scope for (y=1;y<=i;y++) ^ expresie5.cpp:14:9: error: 's' was not declared in this scope s=s+x; ^ expresie5.cpp:16:31: error: 's' was not declared in this scope cout<<"Rezultatul este "<<s; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Expresie5 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ă.