2324549627 发表于 2020-2-16 21:38:19

我这个数组运行起来结果是错的

#include<stdio.h>
int main()
{
        int i,j,row=0,column=0,max;
        int a={{5,6,8,9},{10,12,1,2},{3,4,7,-11}};
        max=a;
        for(i=0;i<3;i++)
        for(j=0;j<4;j++)
        if(a>max)
        {
        max=a;
        row=i;
        column=j;
        }
printf(" max=%d\n row=%d\n column=%d\n",max,i,j);
return 0;
}

人造人 发表于 2020-2-16 21:46:33

你怎么知道是错的?
请说明你期望的运行结果和现在的运行结果

2324549627 发表于 2020-2-16 22:02:38

人造人 发表于 2020-2-16 21:46
你怎么知道是错的?
请说明你期望的运行结果和现在的运行结果

我需要求出那个几行几列为最大值

4goodworld 发表于 2020-2-16 22:29:38


你运行出来是啥结果呢?

良弓无箭 发表于 2020-2-17 07:20:43

这样应该对了。
#include<stdio.h>
int main()
{
      int i,j,row=0,column=0,max1,max2;
      int a={{5,6,8,9},{10,12,1,2},{3,4,7,-11}};
      max1=a;
      for(i=0;i<3;i++)
      for(j=0;j<4;j++)
      if(a>max1)
      {
      max1=a;
              row=i;
              column=j;
      }
      
               
printf(" max=%d\n row=%d\n column=%d\n",max1,row,column);
return 0;
}

pengjiandong 发表于 2020-2-17 20:56:25

#include<stdio.h>
int main()
{
      int i,j,row=0,column=0,max;
      int a={{5,6,8,9},{10,12,1,2},{3,4,7,-11}};
      max=a;
      for(i=0;i<3;i++)
      for(j=0;j<4;j++)
      if(a>max)
      {
      max=a;
      row=i;
      column=j;
      }
printf(" max=%d\n row=%d\n column=%d\n",max,row+1,column+1);
return 0;
}

对的
页: [1]
查看完整版本: 我这个数组运行起来结果是错的