#1157
KSort2
Se dă un vector cu n
elemente, numere naturale și un număr k
. Ordonați crescător primele k
elemente ale vectorului și descrescător ultimele n-k
elemente.
Pentru sortare se va folosit metoda QuickSort sau MergeSort.
Problema | KSort2 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.3 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #48892215 | Utilizator | |
Fișier | ksort2.cpp | Dimensiune | 1.23 KB |
Data încărcării | 08 Februarie 2024, 14:27 | Scor / rezultat | Eroare de compilare |
ksort2.cpp: In function 'void MergeSort(int*, int, int)': ksort2.cpp:17:11: error: 'h' was not declared in this scope tmp[++h] = v[i++]; ^ ksort2.cpp:19:11: error: 'h' was not declared in this scope tmp[++h] = v[j++]; ^ ksort2.cpp:21:10: error: 'h' was not declared in this scope tmp[++h] = v[i++]; ^ ksort2.cpp:23:10: error: 'h' was not declared in this scope tmp[++h] = v[j++]; ^ ksort2.cpp:14:26: warning: unused variable 'k' [-Wunused-variable] int i = st, j = m + 1, k = 0; ^ ksort2.cpp: In function 'void MergeSort1(int*, int, int)': ksort2.cpp:40:11: error: 'h' was not declared in this scope tmp[++h] = v[i++]; ^ ksort2.cpp:42:11: error: 'h' was not declared in this scope tmp[++h] = v[j++]; ^ ksort2.cpp:44:10: error: 'h' was not declared in this scope tmp[++h] = v[i++]; ^ ksort2.cpp:46:10: error: 'h' was not declared in this scope tmp[++h] = v[j++]; ^ ksort2.cpp:37:26: warning: unused variable 'k' [-Wunused-variable] int i = st, j = m + 1, k = 0; ^ ksort2.cpp: In function 'int main()': ksort2.cpp:61:19: error: cannot convert 'long long int*' to 'int*' for argument '1' to 'void MergeSort(int*, int, int)' MergeSort(v,1,k); ^ ksort2.cpp:63:20: error: cannot convert 'long long int*' to 'int*' for argument '1' to 'void MergeSort1(int*, int, int)' MergeSort1(v,k+1,n); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema KSort2 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ă.