#1509
NrMaxim
C++
Să se scrie o funcție care are ca parametru un număr natural n
și returnează cel mai mare număr care poate fi obținut mutând, pe rând, prima cifră a numărului n
și a celor obținute pe parcurs, pe ultima poziție. Nu se vor folosi șiruri de caractere și tablouri auxiliare.
Admitere Mate-Info UBB, iulie 2015
Problema | NrMaxim | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #31019799 | Utilizator | |
Fișier | nrmaxim.cpp | Dimensiune | 481 B |
Data încărcării | 29 Septembrie 2021, 15:44 | Scor / rezultat | Eroare de compilare |
nrmaxim.cpp: In function 'void nrmaxim()': nrmaxim.cpp:10:19: error: 'lungime' was not declared in this scope for(int i=0;i<lungime;i++) ^ nrmaxim.cpp:12:9: error: 'p' was not declared in this scope p=pow(10,lungime); ^ nrmaxim.cpp:13:9: error: 'n' was not declared in this scope n=n/10+b%10*p; ^ nrmaxim.cpp:13:16: error: 'b' was not declared in this scope n=n/10+b%10*p; ^ nrmaxim.cpp:14:9: error: 'maxim' was not declared in this scope maxim=0; ^ nrmaxim.cpp:18:14: error: 'maxim' was not declared in this scope cout >> maxim; ^ nrmaxim.cpp: In function 'int main()': nrmaxim.cpp:28:15: error: lvalue required as left operand of assignment while(n/10=!0) ^ nrmaxim.cpp:31:22: error: too many arguments to function 'void nrmaxim()' cout >> nrmaxim(n); ^ nrmaxim.cpp:8:6: note: declared here void nrmaxim() ^ nrmaxim.cpp:31:10: error: no match for 'operator>>' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'void') cout >> nrmaxim(n); ^ nrmaxim.cpp:31:10: note: candidates are: In file included from /usr/include/c++/4.8/string:53:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from nrmaxim.cpp:1: /usr/include/c++/4.8/bits/basic_string.tcc:996:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&) operator>>(basic_istream<_CharT, _Traits>& __in, ^ /usr/include/c++/4.8/bits/basic_string.tcc:996:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/istream:882:0, from /usr/include/c++/4.8/iostream:40, from nrmaxim.cpp:1: /usr/include/c++/4.8/bits/istream.tcc:955:5: note: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*) operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) ^ /usr/include/c++/4.8/bits/istream.tcc:955:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/istream:882:0, from /usr/include/c++/4.8/iostream:40, from nrmaxim.cpp:1: /usr/include/c++/4.8/bits/istream.tcc:923:5: note: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&) operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) ^ /usr/include/c++/4.8/bits/istream.tcc:923:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/iostream:40:0, from nrmaxim.cpp:1: /usr/include/c++/4.8/istream:727:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&) operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) ^ /usr/include/c++/4.8/istream:727:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<char, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/iostream:40:0, from nrmaxim.cpp:1: /usr/include/c++/4.8/istream:732:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&) operator>>(basic_istream<char, _Traits>& __in, signed char& __c) ^ /usr/include/c++/4.8/istream:732:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<char, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/iostream:40:0, from nrmaxim.cpp:1: /usr/include/c++/4.8/istream:774:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*) operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) ^ /usr/include/c++/4.8/istream:774:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<char, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/iostream:40:0, from nrmaxim.cpp:1: /usr/include/c++/4.8/istream:779:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*) operator>>(basic_istream<char, _Traits>& __in, signed char* __s) ^ /usr/include/c++/4.8/istream:779:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<char, _Traits>' cout >> nrmaxim(n); ^ In file included from /usr/include/c++/4.8/iostream:40:0, from nrmaxim.cpp:1: /usr/include/c++/4.8/istream:872:5: note: template<class _CharT, class _Traits, class _Tp> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ /usr/include/c++/4.8/istream:872:5: note: template argument deduction/substitution failed: nrmaxim.cpp:31:22: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>' cout >> nrmaxim(n); ^ nrmaxim.cpp:23:19: warning: unused variable 'maxim' [-Wunused-variable] int n,lungime,maxim,p; ^ nrmaxim.cpp:23:25: warning: unused variable 'p' [-Wunused-variable] int n,lungime,maxim,p; ^ nrmaxim.cpp: In function 'int main()': nrmaxim.cpp:37:5: error: redefinition of 'int main()' int main(){ ^ nrmaxim.cpp:21:5: error: 'int main()' previously defined here int main(){ ^ nrmaxim.cpp:40:23: error: too many arguments to function 'void nrmaxim()' int y = nrmaxim(x); ^ nrmaxim.cpp:8:6: note: declared here void nrmaxim() ^ nrmaxim.cpp:40:23: error: void value not ignored as it ought to be int y = nrmaxim(x); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrMaxim 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ă.