Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("matrice.in")
int main ()
{
int n, i, j, max1=-99999, max2=-99999, max3=-99999, a[100][100];
f>>n;
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
f>>a[i][j];
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
{
if(i==j)
if(a[i][j]>max1)
max1=a[i][j];
if(i<j)
if(a[i][j]>max2)
max2=a[i][j];
if(i>j)
if(a[i][j]>max3)
max3=a[i][j];
}
cout<<max1<<" "<<max2<<" "<<max3;
Explicație: