作业帮 > 综合 > 作业

c语言 填空题 输出最大值的行列数

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/09 05:53:16
c语言 填空题 输出最大值的行列数
#include
main()
{
int i,j,row=0,colum=0,max;
static int a[3][4]={{1,2,3,4},{11,8,16,6},{10,-10,-4,4}};
_____;
for(i=0;i
#include<stdio.h>

int main()
{
 int i,j,row=0,colum=0,max;
 static int a[3][4]={{1,2,3,4},{11,8,16,6},{10,-10,-4,4}};
 max = a[0][0];
 
    for(i=0;i<=2;i++)
   for(j=0;j<=3;j++)
   {
    if (max < a[i][j]) {
    max = a[i][j];
    row = i;
    colum = j;
    };
   }
   
 printf("%d %d\n",row,colum);
}
再问: 我觉得row = i; colum = j; 这两句应该改成 row=i+1; colum=j+1; 你觉得呢?
再答: 这就要看下标是从 0 起始还是 1 起始。如果是 1 起始,那么主程序第1行也要修改:int i,j,row=1,colum=1,max; // 0 改为 1