#4260
Folosind metoda Divide et Impera, scrieți funcția recursivă cu antetul
int NrXDivImp(int a[], int st, int dr, int x)
care primind ca parametri un vector a de numere întregi și trei numere întregi st, dr și x, returnează numărul de apariții ale numărului x în secvența a[st], a[st+1], ..., a[dr].
| Problema | NrXDivImp | Operații I/O |
nrxdivimp.in/nrxdivimp.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64200863 | Utilizator | |
| Fișier | nrxdivimp.cpp | Dimensiune | 286 B |
| Data încărcării | 22 Aprilie 2026, 17:37 | Scor/rezultat | Eroare de compilare |
nrxdivimp.cpp: In function ‘int NrXDivImp(int*, int, int, int)’: nrxdivimp.cpp:11:9: error: expected ‘}’ before ‘else’ 11 | else | ^~~~ nrxdivimp.cpp:5:19: note: to match this ‘{’ 5 | if (st == dr) { | ^ nrxdivimp.cpp:14:16: error: ‘NrxDivImp’ was not declared in this scope; did you mean ‘NrXDivImp’? 14 | return NrxDivImp (a,st,m,x)+NrXDivImp (a.st,m+1,dr,x) | ^~~~~~~~~ | NrXDivImp nrxdivimp.cpp:14:50: error: request for member ‘st’ in ‘a’, which is of non-class type ‘int*’ 14 | return NrxDivImp (a,st,m,x)+NrXDivImp (a.st,m+1,dr,x) | ^~ nrxdivimp.cpp:14:62: error: expected ‘;’ before ‘int’ 14 | return NrxDivImp (a,st,m,x)+NrXDivImp (a.st,m+1,dr,x) | ^ | ; 15 | 16 | int main() | ~~~ nrxdivimp.cpp:16:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 16 | int main() | ^~ nrxdivimp.cpp:16:9: note: remove parentheses to default-initialize a variable 16 | int main() | ^~ | -- nrxdivimp.cpp:16:9: note: or replace parentheses with braces to value-initialize a variable nrxdivimp.cpp:17:1: error: a function-definition is not allowed here before ‘{’ token 17 | { | ^ nrxdivimp.cpp:28:2: error: expected ‘}’ at end of input 28 | } | ^ nrxdivimp.cpp:12:9: note: to match this ‘{’ 12 | { | ^ nrxdivimp.cpp:28:2: error: expected ‘}’ at end of input 28 | } | ^ nrxdivimp.cpp:4:47: note: to match this ‘{’ 4 | int NrXDivImp(int a[], int st, int dr, int x) { | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrXDivImp 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ă.