#include <iostream>
using namespace std;
void sortowanieDwuWymiarowe(int arr[][5], const int firstSize, const int secoundSize);
int main()
{
const int ONESIZE = 4;
const int TWOSIZE = 5;
int arr[ONESIZE][TWOSIZE] = {0};
for(int i = 0; i < ONESIZE; i++) {
for(int j = 0; j < TWOSIZE; j++) {
cin>>arr[i][j];
}
}
cout<<endl;
sortowanieDwuWymiarowe(arr, ONESIZE, TWOSIZE);
for(int i = 0; i < ONESIZE; i++) {
for(int j = 0; j < TWOSIZE; j++) {
cout<<arr[i][j]<<" ";
}
}
return 0;
}
void Qsort(int arr[][5], int first, int last) {
if(first > last) {
return;
}
int left = first, right = last+1;
int pivot = arr[first/5][first%5];
while(true) {
do {
left++;
}while(left <= last and arr[left/5][left%5] < pivot);
do {
right--;
}while(arr[right/5][right%5] > pivot);
if(left > right) {
break;
}
swap(arr[left/5][left%5],arr[right/5][right%5]);
}
swap(arr[first/5][first%5],arr[right/5][right%5]);
first++;
Qsort(arr,first,right - 1);
Qsort(arr,right + 1,last - 1);
}
void sortowanieDwuWymiarowe(int arr[][5], const int firstSize, const int secoundSize) {
Qsort(arr,0, firstSize*secoundSize-1);
}
Aktualnie mam coś takiego i działa to dla danych wprowadzanych od końca np 20,19,18,...,3,2,1 lecz dla typowo losowych danych już przestaje działać