#236
Fişierul text sort2.in conţine, dispuse pe mai multe linii, cel mult 100 de numere naturale, cu cel mult 4 cifre fiecare. Să se afişeze în fişierul sort2.out, în ordine crescătoare, toate numerele din fişierul sort2.in care au cel mult 2 cifre.
Variante Bacalaureat 2009
| Problema | Sort2 | Operații I/O |
sort2.in/sort2.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64782160 | Utilizator | |
| Fișier | sort2.cpp | Dimensiune | 713 B |
| Data încărcării | 30 Mai 2026, 15:30 | Scor/rezultat | Eroare de compilare |
sort2.cpp:3:14: error: empty character constant 3 | ifstream cin(''sort2.in''); | ^~~~~~~ sort2.cpp:3:24: error: empty character constant 3 | ifstream cin(''sort2.in''); | ^~ sort2.cpp:4:15: error: empty character constant 4 | ofstream cout(''sort2.out''); | ^~~~~~~ sort2.cpp:4:26: error: empty character constant 4 | ofstream cout(''sort2.out''); | ^~ sort2.cpp:26:34: warning: character constant too long for its type 26 | cout<<'NU EXISTA'; | ^~~~~~~~~~~ sort2.cpp:3:14: error: unable to find character literal operator ‘operator""sort2’ with ‘char’ argument 3 | ifstream cin(''sort2.in''); | ^~~~~~~ sort2.cpp:4:15: error: unable to find character literal operator ‘operator""sort2’ with ‘char’ argument 4 | ofstream cout(''sort2.out''); | ^~~~~~~ sort2.cpp: In function ‘int main()’: sort2.cpp:18:40: warning: left operand of comma operator has no effect [-Wunused-value] 18 | swap(a[i,a[j]); | ^ sort2.cpp:18:46: error: expected ‘]’ before ‘)’ token 18 | swap(a[i,a[j]); | ^ | ] sort2.cpp:18:37: error: no matching function for call to ‘swap(int&)’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ In file included from /usr/include/c++/13/bits/exception_ptr.h:41, from /usr/include/c++/13/exception:164, from /usr/include/c++/13/ios:41, from /usr/include/c++/13/istream:40, from /usr/include/c++/13/fstream:40, from sort2.cpp:1: /usr/include/c++/13/bits/move.h:189:5: note: candidate: ‘template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)’ 189 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/13/bits/move.h:189:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: candidate expects 2 arguments, 1 provided 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ /usr/include/c++/13/bits/move.h:213:5: note: candidate: ‘template<class _Tp, long unsigned int _Nm> std::__enable_if_t<std::__is_swappable<_Tp>::value> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])’ 213 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/13/bits/move.h:213:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘_Tp [_Nm]’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ In file included from /usr/include/c++/13/bits/stl_algobase.h:64, from /usr/include/c++/13/string:51, 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: /usr/include/c++/13/bits/stl_pair.h:879:5: note: candidate: ‘template<class _T1, class _T2> void std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)’ 879 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/13/bits/stl_pair.h:879:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘std::pair<_T1, _T2>’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ In file included from /usr/include/c++/13/string:54: /usr/include/c++/13/bits/basic_string.h:3994:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Alloc>&, __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3994 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/13/bits/basic_string.h:3994:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ /usr/include/c++/13/fstream:1271:5: note: candidate: ‘template<class _CharT, class _Traits> void std::swap(basic_filebuf<_CharT, _Traits>&, basic_filebuf<_CharT, _Traits>&)’ 1271 | swap(basic_filebuf<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/13/fstream:1271:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘std::basic_filebuf<_CharT, _Traits>’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ /usr/include/c++/13/fstream:1278:5: note: candidate: ‘template<class _CharT, class _Traits> void std::swap(basic_ifstream<_CharT, _Traits>&, basic_ifstream<_CharT, _Traits>&)’ 1278 | swap(basic_ifstream<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/13/fstream:1278:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘std::basic_ifstream<_CharT, _Traits>’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ /usr/include/c++/13/fstream:1285:5: note: candidate: ‘template<class _CharT, class _Traits> void std::swap(basic_ofstream<_CharT, _Traits>&, basic_ofstream<_CharT, _Traits>&)’ 1285 | swap(basic_ofstream<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/13/fstream:1285:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘std::basic_ofstream<_CharT, _Traits>’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ /usr/include/c++/13/fstream:1292:5: note: candidate: ‘template<class _CharT, class _Traits> void std::swap(basic_fstream<_CharT, _Traits>&, basic_fstream<_CharT, _Traits>&)’ 1292 | swap(basic_fstream<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/13/fstream:1292:5: note: template argument deduction/substitution failed: sort2.cpp:18:37: note: mismatched types ‘std::basic_fstream<_CharT, _Traits>’ and ‘int’ 18 | swap(a[i,a[j]); | ~~~~^~~~~~~~~~ /usr/include/c++/13/bits/exception_ptr.h:230:5: note: candidate: ‘void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)’ 230 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/13/bits/exception_ptr.h:230:5: note: candidate expects 2 arguments, 1 provided sort2.cpp:19:9: error: expected ‘;’ before ‘for’ 19 | ok=0 | ^ | ; 20 | for(i=0;i<n;i++) | ~~~ sort2.cpp:20:14: warning: statement has no effect [-Wunused-value] 20 | for(i=0;i<n;i++) | ~^~ sort2.cpp:20:20: error: expected ‘;’ before ‘)’ token 20 | for(i=0;i<n;i++) | ^ | ; sort2.cpp:25:7: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 25 | if(ok==0) | ^~ sort2.cpp:27:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 27 | return 0; | ^~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Sort2 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ă.