#920
CifMaxMinRec
C++
Să se scrie o funcție C++ recursivă care să determine cifra maximă și cifra minimă a unui număr natural transmis ca parametru. Funcția va întoarce rezultatele prin intermediul unor parametri de ieșire.
Problema | CifMaxMinRec | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54324337 | Utilizator | |
Fișier | cifmaxminrec.cpp | Dimensiune | 307 B |
Data încărcării | 25 Noiembrie 2024, 19:44 | Scor / rezultat | Eroare de compilare |
cifmaxminrec.cpp: In function 'int cifmaxmin(int)': cifmaxminrec.cpp:7:31: error: no matching function for call to 'max(int)' int copie = max(n / 10); ^ cifmaxminrec.cpp:7:31: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cifmaxminrec.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: cifmaxminrec.cpp:7:31: note: candidate expects 2 arguments, 1 provided int copie = max(n / 10); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cifmaxminrec.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: cifmaxminrec.cpp:7:31: note: candidate expects 3 arguments, 1 provided int copie = max(n / 10); ^ cifmaxminrec.cpp:12:29: error: no matching function for call to 'min(int)' else{ int c = min(n / 10); ^ cifmaxminrec.cpp:12:29: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cifmaxminrec.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template argument deduction/substitution failed: cifmaxminrec.cpp:12:29: note: candidate expects 2 arguments, 1 provided else{ int c = min(n / 10); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cifmaxminrec.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:239:5: note: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:239:5: note: template argument deduction/substitution failed: cifmaxminrec.cpp:12:29: note: candidate expects 3 arguments, 1 provided else{ int c = min(n / 10); ^ cifmaxminrec.cpp: In function 'int main()': cifmaxminrec.cpp:22:31: error: too many arguments to function 'int cifmaxmin(int)' cifmaxmin(x, mmax, mmin); ^ cifmaxminrec.cpp:4:5: note: declared here int cifmaxmin(int n) { ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CifMaxMinRec 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ă.