#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 | #63814781 | Utilizator | |
| Fișier | nrxdivimp.cpp | Dimensiune | 293 B |
| Data încărcării | 19 Martie 2026, 20:18 | Scor/rezultat | Eroare de compilare |
nrxdivimp.cpp: In function 'int NrXDivImp(int*, int, int, int)': nrxdivimp.cpp:9:13: error: declaration of 'int a' shadows a parameter int a = NrXDivImp(int a[], int st, int m, int x); ^ nrxdivimp.cpp:9:27: error: expected primary-expression before 'int' int a = NrXDivImp(int a[], int st, int m, int x); ^ nrxdivimp.cpp:9:36: error: expected primary-expression before 'int' int a = NrXDivImp(int a[], int st, int m, int x); ^ nrxdivimp.cpp:9:44: error: expected primary-expression before 'int' int a = NrXDivImp(int a[], int st, int m, int x); ^ nrxdivimp.cpp:9:51: error: expected primary-expression before 'int' int a = NrXDivImp(int a[], int st, int m, int x); ^ nrxdivimp.cpp:10:27: error: expected primary-expression before 'int' int b = NrXDivImp(int a[], int m+1, int dr, int x); ^ nrxdivimp.cpp:10:36: error: expected primary-expression before 'int' int b = NrXDivImp(int a[], int m+1, int dr, int x); ^ nrxdivimp.cpp:10:45: error: expected primary-expression before 'int' int b = NrXDivImp(int a[], int m+1, int dr, int x); ^ nrxdivimp.cpp:10:53: error: expected primary-expression before 'int' int b = NrXDivImp(int a[], int m+1, int dr, int x); ^ nrxdivimp.cpp:5:9: warning: unused variable 's' [-Wunused-variable] int s = 0; ^ nrxdivimp.cpp:8:13: warning: unused variable 'm' [-Wunused-variable] int m = (st + dr) / 2; ^
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ă.