#336
Să se scrie un program care citește numărul natural n și determină suma S=1*n+2*(n-1)+3*(n-2)+...+n*1.
| Problema | Expresie4 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64562771 | Utilizator | |
| Fișier | expresie4.cpp | Dimensiune | 256 B |
| Data încărcării | 14 Mai 2026, 13:31 | Scor/rezultat | Eroare de compilare |
expresie4.cpp: In function ‘int main()’: expresie4.cpp:10:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 10 | while (i=1; i<=n; i+1=n-1) | ~^~ expresie4.cpp:10:14: error: expected ‘)’ before ‘;’ token 10 | while (i=1; i<=n; i+1=n-1) | ~ ^ | ) expresie4.cpp:10:3: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation] 10 | while (i=1; i<=n; i+1=n-1) | ^~~~~ expresie4.cpp:10:16: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’ 10 | while (i=1; i<=n; i+1=n-1) | ^ expresie4.cpp:10:17: warning: statement has no effect [-Wunused-value] 10 | while (i=1; i<=n; i+1=n-1) | ~^~~ expresie4.cpp:10:23: error: lvalue required as left operand of assignment 10 | while (i=1; i<=n; i+1=n-1) | ~^~ expresie4.cpp:22:10: error: expected ‘;’ before ‘}’ token 22 | cout<<S | ^ | ; 23 | } | ~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Expresie4 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ă.