第43题
请编写一个函数fun,它的功能是:求出一个2×M整型二维数组中
最大元素的值,并将此值返回调用函数。注意部分源程序存在文件
PROG1.C文件中。
请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花
括号中埴入你编写的若干语句。
/**********code.c**********/
#include <stdio.h>
#define M 4
int fun (int a[][M])
{
}
void main()
{
int arr[2][M]={5,8,3,45,76,-4,12,82};
printf("max =%d\n", fun(arr));
}
参考答案:
int fun (int a[][M])
{
int i,j,max=a[0][0];
for(i=0;i<2;i++)
for(j=0;j<M;j++)
if(max<a[i][j])
max=a[i][j];
return max;
}