解题思路:


C语言中 各数据类型取绝对值的不同函数:

int abs(int i)


double fabs(double i)


float fabsf(float i)


long double fabsl(long double i)
注意事项:

参考代码:

#include<stdio.h>
#include<math.h>
int main()
{
	int a[3][4],max=0,row=0,column=0;
	for(int i=0;i<3;i++)
	{
	    for(int j=0;j<4;j++)
	    {
	        scanf("%d",&a[i][j]);
	        a[i][j]=abs(a[i][j]);
	    }
	}
	for(int i=0;i<3;i++)
	{
	    for(int j=0;j<4;j++)
	    {
	        if(max<a[i][j])
	        {
	            
	            max=a[i][j];
	            row=i;
	            column=j;
	        }
	        else if(max==a[i][j]&&j<column)
	        {
	            row=i;
	            column=j;
	        }
	    }
	}
	printf("%d %d %d",max,row+1,column+1);
	return 0;
}


 

0.0分

0 人评分

  评论区

  • «
  • »