#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a[n][n]; for(int i=0;i<n;i++){ for(int j=0;j<n-i;j++){ a[i][j]=i+j+1; } for(int j=n-1;j>=i;j--){ a[n-1-i][j]=n-j+i; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<setw(3)<<a[i][j]; } cout<<endl; } } // 1 2 3 4 5 // 11 12 13 14 15 // 2 3 4 5 4 // 21 22 23 24 25 // 3 4 5 4 3 // 31 32 33 34 35 // 4 5 4 3 2 // 41 42 43 44 45 // 5 4 3 2 1 // 51 52 53 54 55 /************************************************************** Problem: 1193 User: wuzhijing Language: C++ Result: Accepted Time:12 ms Memory:2072 kb ****************************************************************/