#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define size 4
void ordenaMatriz (int n, int mat[size][size]) {
int i, j, l, c;
n = size;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
for (l = 0; l < n; l++) {
for (c = 0; c < n; c++) {
if (mat[i][j] < mat[l][c]) {
int aux = mat[i][j];
mat[i][j] = mat[l][c];
mat[l][c] = aux;
}
}
}
}
}
}
int main (void) {
int i, j, n = size, mat[size][size];
srand(time(NULL));
printf("\n ORDENACAO DE MATRIZES\n");
printf("\n\n Ordem Inicial:\n\n");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
mat[i][j] = rand() % 99 +1;
printf(" %02d", mat[i][j]);
}
printf("\n");
}
ordenaMatriz(size, mat);
//ordenaMatriz(n, mat);
printf("\n\n Apos Ordenacao:\n\n");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
printf(" %.2d", mat[i][j]);
}
printf("\n");
}
printf("\n\n ");
system("pause");
return 0;
}