#include #include #include using namespace std; //ifstream f ("date.in"); const int NMAX = 100 + 1; int n, m; int v[NMAX * NMAX]; void citeste() { cin >> n; m = n * n; for (int i = 1; i <= m; i++) cin >> v[i]; } void rezolva() { int x = n + 1, x2 = 1; for (int i = 1; i <= n; i++, cout << '\n') for (int j = 1; j <= n; j++, cout << ' ') if (i == j) { cout << v[x2]; x2++; } else { cout << v[x]; x++; } } inline bool comp(int a, int b) { return a > b; } int main() { citeste(); sort(v + 1, v + m + 1, comp); rezolva(); return 0; }