Răspuns :
Răspuns: Sper ca la asta te refereai :).Complieaza-l sa vezi daca merge.
#include <iostream>
using namespace std;
unsigned int n,i,j;
int main()
{
cin>>n;
unsigned int a[n][n];
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
cout<<"Elementele de pe diagonala principala sunt:";
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(i==j)
cout<<a[i][j]<<' ';
cout<<endl;
cout<<"Elementele de pe diagonala secundara sunt:";
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(i+j==n-1)
cout<<a[i][j]<<' ';
cout<<endl;
cout<<"Elementele de sub diagonala principala sunt:";
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(i>j)
cout<<a[i][j]<<' ';
cout<<endl;
cout<<"Elementele de sub diagonala secundara sunt:";
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(i+j>=n)
cout<<a[i][j]<<' ';
return 0;
}
Explicație: