#897
Să se scrie o funcție C++ care să returneze suma cifrelor unui număr natural transmis ca parametru.
| Problema | SumCifF | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64554532 | Utilizator | |
| Fișier | sumciff.cpp | Dimensiune | 241 B |
| Data încărcării | 14 Mai 2026, 09:20 | Scor/rezultat | Eroare de compilare |
sumciff.cpp: In function ‘int main()’: sumciff.cpp:9:12: error: ‘n’ was not declared in this scope 9 | while (n) | ^ sumciff.cpp:16:18: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 16 | int main () | ^~ sumciff.cpp:16:18: note: remove parentheses to default-initialize a variable 16 | int main () | ^~ | -- sumciff.cpp:16:18: note: or replace parentheses with braces to value-initialize a variable sumciff.cpp:17:9: error: expected initializer before ‘int’ 17 | int n; | ^~~ sumciff.cpp:18:14: error: ‘n’ was not declared in this scope 18 | cin>>n; | ^ sumciff.cpp:19:15: error: ‘sumcif’ was not declared in this scope 19 | cout<<sumcif(n); | ^~~~~~ sumciff.cpp: At global scope: sumciff.cpp:24:5: error: redefinition of ‘int main()’ 24 | int main(){ | ^~~~ sumciff.cpp:6:5: note: ‘int main()’ previously defined here 6 | int main() | ^~~~ sumciff.cpp: In function ‘int main()’: sumciff.cpp:27:21: error: ‘sumcif’ was not declared in this scope 27 | int y = sumcif(x); | ^~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema SumCifF face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.