#include
#include
#define M 4
#define N 5
int fun (int a[M][N])
{
int i,j,sum=0;
for (i=0;i
for (j=0;j
}
return(sum);
}
void main()
{
int aa[M][N]={{1,3,5,7,9},{2,9,9,9,4},{6,9,9,9,8}, {1,3,5,7,0}};
int i, j, y;
void NONO ();
printf ("The original data is : \n");
for (i=0; i
for (j =0; j
printf ("\n");
}
y = fun (aa);
printf("\nThe sum: %d\n" , y);
printf("\n");
NONO();
}
void NONO ()
{/* 请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。 */
int i, j, y, k, aa[M][N] ;
FILE *rf, *wf ;
rf = fopen("in.dat","r");
wf = fopen("out.dat","w");
for(k = 0 ; k < 10 ; k++) {
for(i = 0 ; i < M ; i++)
for(j = 0 ; j < N ; j++)
fscanf(rf,"%d", &aa[i][j]);
y = fun (aa);
fprintf(wf,"%d\n", y);
}
fclose(rf);
fclose(wf);
}