include stdafx include math include iostream using namespace std doubl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "stdafx.h"
#include "math.h"
#include <iostream>
using namespace std;
double f (int ** A, int m)
{
int k=0;
int sum=0;
for (int i=0; i<m; i++)
for (int j=0;j<i;j++)
{
sum+=A[i][j];
k++;
}
return (double) sum/k;
}
void main()
{ int m;
cin>>m;
int** a= new int* [m];
for (int i=0;i<m;i++)
a[i]=new int [m];
for (int i=0; i<m; i++)
for (int j=0;j<m;j++)
cin>>a[i][j];
cout<<f(a,m);
for (int i=0;i<m;i++)
delete [] a[i];
}