#516
Se dă un vector format din n elemente, numere naturale. Calculați suma elementelor din secvența determinată de primul și ultimul element impar.
| Problema | SumSec1 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64787242 | Utilizator | |
| Fișier | sumsec1.cpp | Dimensiune | 514 B |
| Data încărcării | 31 Mai 2026, 15:28 | Scor/rezultat | Eroare de compilare |
sumsec1.cpp: In function ‘int main()’: sumsec1.cpp:9:21: error: expected ‘;’ before ‘<’ token 9 | for(int i = 0, i < n; i++) | ^~ | ; sumsec1.cpp:9:22: error: expected primary-expression before ‘<’ token 9 | for(int i = 0, i < n; i++) | ^ sumsec1.cpp:10:20: error: expected ‘;’ before ‘int’ 10 | cin >> v[i] | ^ | ; 11 | 12 | int p, u; | ~~~ sumsec1.cpp:15:19: error: expected primary-expression before ‘==’ token 15 | if(v[i] % == 1) | ^~ sumsec1.cpp:17:9: error: ‘p’ was not declared in this scope 17 | p = i; | ^ sumsec1.cpp:24:13: error: ‘u’ was not declared in this scope 24 | u = 1 | ^ sumsec1.cpp:27:18: error: ‘p’ was not declared in this scope 27 | for (int i = p; i <= u; i++) | ^ sumsec1.cpp:27:26: error: ‘u’ was not declared in this scope 27 | for (int i = p; i <= u; i++) | ^ sumsec1.cpp:28:9: error: ‘s’ was not declared in this scope 28 | s += v [i]; | ^ sumsec1.cpp:29:13: error: ‘s’ was not declared in this scope 29 | cout << s; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema SumSec1 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ă.