|
|
1鱼币
/********************************************************************************************************************
* 题目: *
* 给定程序blank1.c中,函数fun的功能是:在3行4列的矩阵中找出在行上最大、在列上最小的那个元素, *
* 若没有符合条件的元素则输出相应信息。 *
* 例如,有下列矩阵: *
* 1 2 13 4 *
* 7 8 10 6 *
* 3 5 9 7 *
* 程序执行结果为:find: a[2][2]=9 *
* *
* 答题提示:请先将程序中的“__1__、__2__、__3__”删除,在相应的位置填入正确的答案。最后将答案写到试卷上。 *
*********************************************************************************************************************/
#include <stdio.h>
#define M 3
#define N 4
void fun(int (*a)[N])
{ int i=0,j,find=0,rmax,c,k;
while( (i<M) && (!find))
{ rmax=a[i][0]; c=0;
for(j=1; j<N; j++)
if(rmax<a[i][j]) {
/**********found**********/
rmax=a[i][j]; c=___1___ ; }
find=1; k=0;
while(k<M && find)
{
/**********found**********/
if (k!=i && a[k][c]<=rmax) find=___2___ ;
k++;
}
if(find) printf("find: a[%d][%d]=%d\n",i,c,a[i][c]);
/**********found**********/
___3___;
}
if(!find) printf("not found!\n");
}
main()
{ int x[M][N],i,j;
printf("Enter number for array:\n");
for(i=0; i<M; i++)
for(j=0; j<N; j++) scanf("%d",&x[i][j]);
printf("The array:\n");
for(i=0; i<M; i++)
{ for(j=0; j<N; j++) printf("%3d",x[i][j]);
printf("\n\n");
}
fun(x);
}
|
最佳答案
查看完整内容
c=j; //___1___
find=0; //___2___
i++; //____3____
|