请补充fun函数,该函数的功能是:计算N×N维矩阵元素

请补充fun函数,该函数的功能是:计算N×N维矩阵元素的方差,结果由函数返回。维数在主函数中输入。
例如:

矩阵

的计算结果是14.414。
求方差的公式为:

公式

其中

公式

注意:
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横
线上填入所编写的若干表达式或语句。

/**********code.c**********/
#include <stdio.h>
#include <stdlib.h>
#define N 20
/**********found**********/
double fun(①______,int n)
{
int i,j;
double s=0.0;
double f=0.0;
double aver=0.0;
double sd=0.0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
s+=a[i][j];
/**********found**********/
aver=②______;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
f+=(a[i][j]-aver)*(a[i][j]-aver);
f/=(n*n);
/**********found**********/
sd=③______;
return sd;
}
main()
{
int a[N][N];
int n;
int i,j;
double s;
printf("*****Input the dimension of array n******\n");
scanf("%d",&n);
printf("*****The array*****\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=rand()%50;
while (a[i][j]==0)
a[i][j]=rand()%60;
printf("%4d",a[i][j]);
}
printf("\n\n");
}
s=fun(a,n);
printf("*****THE RESULT*****\n");
printf("%4.3f\n",s);
}
答案
第1空:int a[][N]
第2空:s/(n*n)
第3空:sqrt(f)

题目信息

题号:7618
题型:填空题
难度:普通