#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 | #64078578 | Utilizator | |
| Fișier | sumsec1.cpp | Dimensiune | 538 B |
| Data încărcării | 15 Aprilie 2026, 22:02 | Scor/rezultat | 100 puncte |
sumsec1.cpp: In function ‘int suma(int, int*)’: sumsec1.cpp:24:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 24 | for(i=aa;i<=bb;i++) | ^~~ sumsec1.cpp:26:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 26 | return s; | ^~~~~~ sumsec1.cpp: In function ‘int main()’: sumsec1.cpp:30:9: warning: unused variable ‘i’ [-Wunused-variable] 30 | int i,v[1001],s=0,n; | ^ sumsec1.cpp:30:19: warning: unused variable ‘s’ [-Wunused-variable] 30 | int i,v[1001],s=0,n; | ^ sumsec1.cpp: In function ‘int suma(int, int*)’: sumsec1.cpp:18:14: warning: ‘aa’ may be used uninitialized [-Wmaybe-uninitialized] 18 | for(i=n;i>=aa;i--) | ~^~~~ sumsec1.cpp:11:15: note: ‘aa’ was declared here 11 | int i,s=0,aa,bb; | ^~ sumsec1.cpp:24:15: warning: ‘bb’ may be used uninitialized [-Wmaybe-uninitialized] 24 | for(i=aa;i<=bb;i++) | ~^~~~ sumsec1.cpp:11:18: note: ‘bb’ was declared here 11 | int i,s=0,aa,bb; | ^~
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 1 | 0.001 secunde | OK. | 20 | 20 | Exemplu | |
| 2 | 0.001 secunde | OK. | 40 | 40 | ||
| 3 | 0.001 secunde | OK. | 40 | 40 | ||
| Punctaj total | 100 | |||||
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ă.