#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
 
void wypisz(int (*tab)[10]){
    for(int i=0;i<5;i++){
        for(int j=0;j<10;j++)
            cout << tab[i][j] << "\t";
        cout << endl;
    }
}
 
int main() {
    srand(time(NULL));
    int tab[5][10];
    int liczba = 10;
 
    //    Wypełnianie tablicy danymi
    for(int i=0;i<5;i++)
        for(int j=0;j<10;j++)
            tab[i][j] = rand() % 100 + 1;
 
    cout << "Przed posortowaniem:" << endl;    
    wypisz(tab);
 
    //    Sortowanie
    int temp=0;
    for(int i=0;i<5;i++)
        for(int l=i;l<5;l++)
            for(int j=0;j<10;j++)
                for(int k=j;k<10;k++)
                    if(tab[i][j]>tab[i][k]){
                        temp=tab[i][j];
                        tab[i][j]=tab[i][k];
                        tab[i][k]=temp;
                        j=0;
                    }
                    else if(tab[i][j]>tab[l][j]){
                        temp=tab[i][j];
                        tab[i][j]=tab[l][j];
                        tab[l][j]=temp;
                        i=0;
                    }
 
 
    cout << "Posortowana tablica:" << endl;    
    wypisz(tab);
 
    return 0;
}