#include
int main()
{
int end = 0;
int swap = 0;
int X=0,Y=0;
int n,m;
int data;
int zz = 0;
while(~scanf("%d%d",&m,&n))
{
int count = n * m;
while(zz < count && ~scanf("%d",&data))
{
if(data < 0 && end != (0 -data))
{
swap = 0 - data;
if(end < swap)
{
end = swap;
X = zz / n;
Y = zz % m ;
}
}
else
{
if(end < data)
{
end = data;
X = zz / n;
Y = zz % m;
}
}
zz++;
}
if(end == swap)
{
end = 0 - swap;
}
printf("%d %d %d\n",X+1,Y,end);
end = 0;
swap = 0;
}
return 0;
}
现在的代码不超时了,但是有错误。请参考下面的代码哈,欢迎交流:
#include
#include
int main()
{
int n,m;
int i,j;
int a[100][100];
int max;
int x,y;
while(scanf("%d%d",&n,&m)!=EOF)
{
max=0;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
scanf("%d",&a[i][j]);
if(fabs(a[i][j])>fabs(max))
{
max=a[i][j];
x=i;
y=j;
}
}
printf("%d %d %d\n",x,y,max);
}
return 0;
}