#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 | #64931464 | Utilizator | |
| Fișier | sumciff.cpp | Dimensiune | 140 B |
| Data încărcării | 15 Iunie 2026, 22:33 | Scor/rezultat | Eroare de compilare |
sumciff.cpp: In function ‘int sumcif(int)’: sumciff.cpp:8:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 8 | int main() | ^~ sumciff.cpp:8:9: note: remove parentheses to default-initialize a variable 8 | int main() | ^~ | -- sumciff.cpp:8:9: note: or replace parentheses with braces to value-initialize a variable sumciff.cpp:9:1: error: a function-definition is not allowed here before ‘{’ token 9 | { sum=0; | ^ sumciff.cpp:15:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 15 | int main(){ | ^~ sumciff.cpp:15:9: note: remove parentheses to default-initialize a variable 15 | int main(){ | ^~ | -- sumciff.cpp:15:9: note: or replace parentheses with braces to value-initialize a variable sumciff.cpp:15:11: error: a function-definition is not allowed here before ‘{’ token 15 | int main(){ | ^ sumciff.cpp:22:2: error: expected ‘}’ at end of input 22 | } | ^ sumciff.cpp:7:19: note: to match this ‘{’ 7 | int sumcif(int n){ | ^ sumciff.cpp:22:2: warning: no return statement in function returning non-void [-Wreturn-type] 22 | } | ^
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ă.