第42题
功能:求出二维数组外围元素之和,作为函数值返回。二维数组的值在主函数中赋予。
#define M 4
#define N 5
#include<stdio.h>
int fun(int a[M][N])
{
int s=0;
int i,j;
for(_____1_____)
_____2_____
for(_____3_____)
_____4_____
_____5_____
}
void TestFunc()
{
FILE *IN,*OUT;
int iIN[M][N],iOUT;
int i,j,k;
IN=fopen("14.in","r");
if(IN==NULL)
{
printf("Please Verify The Currernt Dir..It May Be Changed");
}
OUT=fopen("14.out","w");
if(OUT==NULL)
{
printf("Please Verify The Current Dir.. It May Be Changed");
}
for(k=0;k<10;k++)
{
for(i=0;i<M;i++)
for(j=0;j<N;j++)
fscanf(IN,"%d",&iIN[i][j]);
iOUT=fun(iIN);
fprintf(OUT,"%d\n",iOUT);
}
fclose(IN);
fclose(OUT);
}
void main()
{
int a[M][N]={{1,3,5,7,9},{2,4,6,8,10},{2,3,4,5,6},{4,5,6,7,8}};
int y;
y=fun(a);
printf("s=%d\n",y);
TestFunc();
}