Detalii evaluare #64778757

Rezumat problemă

#911

Să se scrie o funcție C++ care primește ca parametri două numere n și k și determină cel mai mare număr care poate fi scris cu k cifre ale lui n. Funcția va întoarce rezultatul prin intermediul unui parametru de ieşire.

Detalii

Problema Cifre6 Operații I/O tastatură/ecran
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #64778757 Utilizator cioban titu (gang_zb)
Fișier cifre6.cpp Dimensiune 372 B
Data încărcării 29 Mai 2026, 21:25 Scor/rezultat Eroare de compilare

Evaluare

Mesaj compilare

cifre6.cpp: In function ‘int numar(std::string, int, int&)’:
cifre6.cpp:7:14: error: no match for ‘operator>’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’)
    7 |      while(n > 0){
      |            ~ ^ ~
      |            |   |
      |            |   int
      |            std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/13/string:48,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from cifre6.cpp:1:
/usr/include/c++/13/bits/stl_iterator.h:469:5: note: candidate: ‘template<class _Iterator> bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’
  469 |     operator>(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:469:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’
    7 |      while(n > 0){
      |                ^
/usr/include/c++/13/bits/stl_iterator.h:514:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  514 |     operator>(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:514:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’
    7 |      while(n > 0){
      |                ^
/usr/include/c++/13/bits/stl_iterator.h:1725:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1725 |     operator>(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1725:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’
    7 |      while(n > 0){
      |                ^
/usr/include/c++/13/bits/stl_iterator.h:1784:5: note: candidate: ‘template<class _Iterator> bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’
 1784 |     operator>(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1784:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’
    7 |      while(n > 0){
      |                ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/string:51:
/usr/include/c++/13/bits/stl_pair.h:848:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’
  848 |     operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:848:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::pair<_T1, _T2>’
    7 |      while(n > 0){
      |                ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:3870:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
 3870 |     operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3870:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’
    7 |      while(n > 0){
      |                ^
/usr/include/c++/13/bits/basic_string.h:3884:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’
 3884 |     operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3884:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   mismatched types ‘const _CharT*’ and ‘int’
    7 |      while(n > 0){
      |                ^
/usr/include/c++/13/bits/basic_string.h:3897:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
 3897 |     operator>(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3897:5: note:   template argument deduction/substitution failed:
cifre6.cpp:7:16: note:   mismatched types ‘const _CharT*’ and ‘std::__cxx11::basic_string<char>’
    7 |      while(n > 0){
      |                ^
cifre6.cpp:8:22: error: no match for ‘operator%’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’)
    8 |         v[cnt++] = n % 10;
      |                    ~ ^ ~~
      |                    |   |
      |                    |   int
      |                    std::string {aka std::__cxx11::basic_string<char>}
cifre6.cpp:9:11: error: no match for ‘operator/=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’)
    9 |         n /= 10;
      |         ~~^~~~~
cifre6.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
cifre6.cpp: In function ‘int main()’:
cifre6.cpp:26:19: error: could not convert ‘x’ from ‘int’ to ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
   26 |             numar(x , y , z);
      |                   ^
      |                   |
      |                   int

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema Cifre6 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:

  • Soluția propusă de tine este inclusă în programul suport, apoi acesta este compilat. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Datorită existenței programului suport, la compilare pot să apară erori sau avertismente care să nu se refere la instrucțiunile scrise de tine, dar care sunt datorate faptului că soluția ta nu este corectă.
  • Dacă programul suport a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

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ă.

Du-te sus!