#include <iostream>
#include <math.h>
using namespace std;
int main()
{int a[50][50],n,i,j;
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
cout<<"a["<<i<<"]["<<j<<"]=";
cin>>a[i][j];
}
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
cout<<endl;
cout<<endl;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(a[i][j]==i+j)
cout<<a[i][j]<<" ";
}
Sper să te ajute! Mult succes!