#1654
Să se scrie o funcție C++ recursivă care returnează numărul de vocale dintr-un şir de caractere transmis ca parametru.
| Problema | NrVocRec | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64641860 | Utilizator | |
| Fișier | nrvocrec.cpp | Dimensiune | 268 B |
| Data încărcării | 20 Mai 2026, 08:33 | Scor/rezultat | Eroare de compilare |
nrvocrec.cpp: In function ‘int nr_vocale(char*)’: nrvocrec.cpp:8:5: error: expected ‘,’ or ‘;’ before ‘if’ 8 | if(strlen(s) == 0) return 0; | ^~ nrvocrec.cpp:9:5: error: ‘else’ without a previous ‘if’ 9 | else | ^~~~ nrvocrec.cpp:10:12: error: ‘strchr’ was not declared in this scope 10 | if(strchr(vocale, s[0]) != NULL) | ^~~~~~ nrvocrec.cpp:2:1: note: ‘strchr’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 1 | #include <iostream> +++ |+#include <cstring> 2 | nrvocrec.cpp:12:9: error: ‘strcpy’ was not declared in this scope 12 | strcpy(s, s + 1); return nr_vocale(s) + 1; | ^~~~~~ nrvocrec.cpp:12:9: note: ‘strcpy’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? nrvocrec.cpp:13:9: error: expected ‘}’ before ‘else’ 13 | else return strcpy(s, s + 1); return(s);} | ^~~~ nrvocrec.cpp:11:5: note: to match this ‘{’ 11 | { | ^ nrvocrec.cpp:13:21: error: ‘strcpy’ was not declared in this scope 13 | else return strcpy(s, s + 1); return(s);} | ^~~~~~ nrvocrec.cpp:13:21: note: ‘strcpy’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? nrvocrec.cpp:13:9: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation] 13 | else return strcpy(s, s + 1); return(s);} | ^~~~ nrvocrec.cpp:13:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’ 13 | else return strcpy(s, s + 1); return(s);} | ^~~~~~ nrvocrec.cpp:13:46: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive] 13 | else return strcpy(s, s + 1); return(s);} | ~^~ | | | char* nrvocrec.cpp: At global scope: nrvocrec.cpp:14:5: error: expected declaration before ‘}’ token 14 | } | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrVocRec 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ă.