#include
int main()
{ int i,j,i0,j0,s,a[3][5]= {5,6,26,9,11,3,1,8,7,33};
i0=j0=s=0;
for(i=0; i<3; i++)
{ for(j=0; j<5; j++)
{ s+=a[i][j];
printf("%3d",a[i][j]);
if(a[i][j] { i0=i;
j0=j;
}
}
printf("\n");
}
printf("Sum=%d\na[%d][%d]=%d\n",s,i0,j0,a[i0][j0]);
return 0;
}
参考代码如下;
#include
int a[3][5]={
5,6,26,9,11,3,1,8,7,33,17,12,15,36,25
};
int main()
{
int i,j,min,sum=0,s=0,t=0;
min=a[0][0];
for(i=0;i<3;++i)
for(j=0;j<4;++j){
sum+=a[i][j];
if(min>a[i][j]){
s=i;
t=j;
min=a[i][j];
}
}
printf("min=%d (%d,%d)\n",min,s,t);
printf("sum=%d",sum);
return 0;
}