Răspuns:
#include <iostream>
#include <algorithm>
using namespace std;
unsigned short A[100][100];
bool cmp(unsigned short a, unsigned short b){return a > b;}
int main(){
int n,m;
cin >> n >> m;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> A[j][i];
for(int j = 0; j < m; j++)
sort(&A[j][0], &A[j][n], cmp);
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)
cout << A[j][i]<<' ';
cout << '\n';
}
}
Explicație:
Poti transforma randurile in coloane si coloanele in randuri. Astfel, trebuie doar sa sortezi randurile(merge si STL sort) si apoi sa afisezi inapoi matricea.