网友您好, 请在下方输入框内输入要搜索的题目:
请编写函数fun(),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如:若二维数组中的值为
1 3 5 7 9
2 9 9 9 4
6 9 9 9 8
1 3 5 7 0
则函数值为61。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio.h>
include<stdio.h>
define M 4
define N 5
int fun( int a [M][N])
{
}
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;
clrscr();
printf ("The original data is :\n ");
for(i=0; i<N;i++)
{for (j=0; j<N;j++)
printf("%6d ",aa[i][j]);
printf("\n ");
}
y=fun(aa);
printf("\nThe sun:%d\n ",y);
printf("\n");
}
参考答案
更多 “ 请编写函数fun(),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。例如:若二维数组中的值为1 3 5 7 92 9 9 9 46 9 9 9 81 3 5 7 0则函数值为61。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>define M 4define N 5int fun( int a [M][N]){}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;clrscr();printf ("The original data is :\n ");for(i=0; i<N;i++){for (j=0; j<N;j++)printf("%6d ",aa[i][j]);printf("\n ");}y=fun(aa);printf("\nThe sun:%d\n ",y);printf("\n");} ” 相关考题
![瑞牛题库 章节练习 历年真题 模拟试卷](http://assets.51tk.com/51_sidebar_right_index.jpg)