You are on page 1of 2

#include <iostream> using namespace std; int main() { int f = 3,c = 3,mayor = 0; int matriz[f][c]; for(int i = 0; i < f; i++)

{ for(int j = 0; j < c; j++) { cout << "Ingresar valor para posicion " << i << " x " << j << ": "; cin >> matriz[i][j]; } } system("cls"); cout << "\nLa matriz original es:\n\n" << endl; for(int i = 0; i < f; i++) { for(int j=0; j<c; j++) { cout << matriz[i][j] << "\t\t"; } cout<<endl; } for(int i = 0; i < f; i++) { for(int j = 0; j < c; j++) { for(int x = 0; x < f;x++) { for(int y = 0; y < c; y++) { if(matriz[i][j] > matriz[x][y]) { mayor = matriz[i][j]; matriz[i][j] = matriz[x][y]; matriz[x][y] = mayor; } } } } } cout << "\nLa matriz ordenada de mayor a menor es:\n\n" << endl; for(int i=0; i<f; i++) { for(int j=0; j<c; j++) { cout << matriz[i][j] << "\t\t"; } cout << "\n\n"; }

system("pause"); }

You might also like