Răspuns :
#include <fstream>
using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");
int main()
{
int n,A[101][101],nr=0;
fin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
fin>>A[i][j];
int si=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(A[i][j]%3==0)
si=si+A[i][j],++nr;
fout<<si/nr<<'\n';
return 0;
}
using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");
int main()
{
int n,A[101][101],nr=0;
fin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
fin>>A[i][j];
int si=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(A[i][j]%3==0)
si=si+A[i][j],++nr;
fout<<si/nr<<'\n';
return 0;
}