Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int m[n+1][n+1];
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= n ; j++)
if(i == n - j + 1)
m[i][j] = 1;
else
m[i][j] = 0;
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= n ; j++)
cout << m[i][j] << " ";
cout << endl;
}
return 0;
}
Explicație: