#827
Să se scrie o funcție C++ recursivă care să returneze cea mai mare cifră pară a unui număr natural transmis ca parametru.
| Problema | CifMaxParRec | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64936362 | Utilizator | |
| Fișier | cifmaxparrec.cpp | Dimensiune | 363 B |
| Data încărcării | 17 Iunie 2026, 06:54 | Scor/rezultat | Eroare de compilare |
cifmaxparrec.cpp: In function ‘int cifmaxpar(int*, int, int, int)’: cifmaxparrec.cpp:5:10: error: overloaded function with no contextual type information 5 | max=-1; | ^ cifmaxparrec.cpp:6:37: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator>’ 6 | if(st==dr && a[st]%2==0 && a[st]>max){ | ~~~~~^~~~ cifmaxparrec.cpp:7:17: error: overloaded function with no contextual type information 7 | max=a[st]; | ^ cifmaxparrec.cpp:8:12: error: cannot resolve overloaded function ‘max’ based on conversion to type ‘int’ 8 | return max; | ^~~ cifmaxparrec.cpp:12:25: error: too few arguments to function ‘int cifmaxpar(int*, int, int, int)’ 12 | int c1=cifmaxpar(a,st,mj); | ~~~~~~~~~^~~~~~~~~ cifmaxparrec.cpp:4:5: note: declared here 4 | int cifmaxpar(int a[],int n,int st,int dr){ | ^~~~~~~~~ cifmaxparrec.cpp:13:25: error: too few arguments to function ‘int cifmaxpar(int*, int, int, int)’ 13 | int c2=cifmaxpar(a,mj+1,dr); | ~~~~~~~~~^~~~~~~~~~~ cifmaxparrec.cpp:4:5: note: declared here 4 | int cifmaxpar(int a[],int n,int st,int dr){ | ^~~~~~~~~ cifmaxparrec.cpp: In function ‘int main()’: cifmaxparrec.cpp:24:31: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive] 24 | int y = cifmaxpar(x); | ^ | | | int cifmaxparrec.cpp:24:30: error: too few arguments to function ‘int cifmaxpar(int*, int, int, int)’ 24 | int y = cifmaxpar(x); | ~~~~~~~~~^~~ cifmaxparrec.cpp:4:5: note: declared here 4 | int cifmaxpar(int a[],int n,int st,int dr){ | ^~~~~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CifMaxParRec 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ă.