#185
Se citește de la tastură un număr natural n, apoi n numere naturale. Să se afişeze cel mai mic număr care poate fi scris folosind prima cifră a numerelor citite.
| Problema | CifInit | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64132289 | Utilizator | |
| Fișier | cifinit.cpp | Dimensiune | 518 B |
| Data încărcării | 19 Aprilie 2026, 18:00 | Scor/rezultat | Eroare de compilare |
cifinit.cpp: In function ‘int main()’: cifinit.cpp:13:19: error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive] 13 | for(i=1;i<=n;i++) | ~^~ cifinit.cpp:16:16: error: no match for ‘operator>’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’) 16 | while(x>9) | ~^~ | | | | | 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 cifinit.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: cifinit.cpp:16:17: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 16 | while(x>9) | ^ /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: cifinit.cpp:16:17: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 16 | while(x>9) | ^ /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: cifinit.cpp:16:17: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’ 16 | while(x>9) | ^ /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: cifinit.cpp:16:17: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’ 16 | while(x>9) | ^ 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: cifinit.cpp:16:17: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::pair<_T1, _T2>’ 16 | while(x>9) | ^ 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: cifinit.cpp:16:17: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’ 16 | while(x>9) | ^ /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: cifinit.cpp:16:17: note: mismatched types ‘const _CharT*’ and ‘int’ 16 | while(x>9) | ^ /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: cifinit.cpp:16:17: note: mismatched types ‘const _CharT*’ and ‘std::__cxx11::basic_string<char>’ 16 | while(x>9) | ^ cifinit.cpp:18:16: error: no match for ‘operator/’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’) 18 | x=x/10; | ~^~~ | | | | | int | std::string {aka std::__cxx11::basic_string<char>} cifinit.cpp:20:11: error: no match for ‘operator[]’ (operand types are ‘int [11]’ and ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}) 20 | ap[x]++; | ^ cifinit.cpp:22:11: error: ambiguous overload for ‘operator=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’) 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/basic_string.h:812:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ 812 | operator=(const basic_string& __str) | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:823:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ 823 | operator=(const _CharT* __s) | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:835:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ 835 | operator=(_CharT __c) | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:853:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ 853 | operator=(basic_string&& __str) | ^~~~~~~~ cifinit.cpp:22:14: error: no match for ‘operator<=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’) 22 | for(i=0;i<=9;i++) | ~^~~ | | | | | int | std::string {aka std::__cxx11::basic_string<char>} /usr/include/c++/13/bits/stl_iterator.h:476:5: note: candidate: ‘template<class _Iterator> bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’ 476 | operator<=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:476:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/stl_iterator.h:520:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’ 520 | operator<=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:520:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/stl_iterator.h:1715:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1715 | operator<=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1715:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/stl_iterator.h:1777:5: note: candidate: ‘template<class _Iterator> bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’ 1777 | operator<=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1777:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/stl_pair.h:854:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator<=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’ 854 | operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/13/bits/stl_pair.h:854:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::pair<_T1, _T2>’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/basic_string.h:3911: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>&)’ 3911 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3911:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/basic_string.h:3925:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’ 3925 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3925:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: mismatched types ‘const _CharT*’ and ‘int’ 22 | for(i=0;i<=9;i++) | ^ /usr/include/c++/13/bits/basic_string.h:3938:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3938 | operator<=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3938:5: note: template argument deduction/substitution failed: cifinit.cpp:22:16: note: mismatched types ‘const _CharT*’ and ‘std::__cxx11::basic_string<char>’ 22 | for(i=0;i<=9;i++) | ^ cifinit.cpp:22:19: error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive] 22 | for(i=0;i<=9;i++) | ~^~ cifinit.cpp:24:17: error: no match for ‘operator[]’ (operand types are ‘int [11]’ and ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}) 24 | while(ap[i]>0) | ^ cifinit.cpp:26:18: error: no match for ‘operator*’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘int’) 26 | nr=nr*10+i; | ~~^~~ | | | | | int | std::string {aka std::__cxx11::basic_string<char>} cifinit.cpp:27:15: error: no match for ‘operator[]’ (operand types are ‘int [11]’ and ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}) 27 | ap[i]--; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CifInit face parte din prima categorie. 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ă.