#512
Se dă un vector cu n elemente, numere naturale distincte. Ordonați crescător elementele situate înaintea valorii maxime din vector și descrescător elementele situate după această valoare.
| Problema | SortMax | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64736246 | Utilizator | |
| Fișier | sortmax.cpp | Dimensiune | 420 B |
| Data încărcării | 26 Mai 2026, 20:39 | Scor/rezultat | Eroare de compilare |
sortmax.cpp: In function ‘int main()’: sortmax.cpp:8:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 8 | for (i=1; i<n; i++) | ^~~ sortmax.cpp:13:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 13 | sort (v, v+poz); | ^~~~ sortmax.cpp:14:14: error: no matching function for call to ‘sort(int*, int&, std::greater<int>)’ 14 | sort (v+poz+1, n, greater <int>()) | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from sortmax.cpp:1: /usr/include/c++/13/bits/stl_algo.h:4851:5: note: candidate: ‘template<class _RAIter> void std::sort(_RAIter, _RAIter)’ 4851 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~ /usr/include/c++/13/bits/stl_algo.h:4851:5: note: template argument deduction/substitution failed: sortmax.cpp:14:14: note: deduced conflicting types for parameter ‘_RAIter’ (‘int*’ and ‘int’) 14 | sort (v+poz+1, n, greater <int>()) | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:4882:5: note: candidate: ‘template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)’ 4882 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, | ^~~~ /usr/include/c++/13/bits/stl_algo.h:4882:5: note: template argument deduction/substitution failed: sortmax.cpp:14:14: note: deduced conflicting types for parameter ‘_RAIter’ (‘int*’ and ‘int’) 14 | sort (v+poz+1, n, greater <int>()) | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sortmax.cpp:15:20: warning: statement has no effect [-Wunused-value] 15 | for (i=0; i<n; i++); | ~^~ sortmax.cpp:15:27: error: expected ‘;’ before ‘)’ token 15 | for (i=0; i<n; i++); | ^ | ;
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema SortMax 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ă.