急死了!!!给定程序中,函数fun的功能是:在3×4的矩阵中

来源:百度知道 编辑:UC知道 时间:2024/05/01 15:12:47
给定程序中,函数fun的功能是:在3×4的矩阵中找出在行上最大、在列上最小的那个元素,若没有符合条件的元素则输出相应信息。 例如,有下列矩阵:
1 2 13 4
7 8 10 6
3 5 9 7
程序执行结果为:find: a[2][2]=9请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
#include <stdio.h>
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);
}

#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;

#include <stdio.h>
#define M 3
#define N 4

void fun(int (*a)[N]);

void 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);
}

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= j ; }
find=1; k=0;
while(k<M && find) {
/**********found**********/
if (k!=i && a[k][c]<=rmax) find= 0 ;
k++;
}
if(find) printf("find: a[%d][%d]=%d\n",i,c,a[i][c]);
/**********found**********/