这道C语言题错在哪里了

2025-04-25 05:29:50
推荐回答(1个)
回答1:

#include
#define line 100
#define row 100
using namespace std;
int main()
{
    int a[line][row], x, y, s;
    int m, n;
    int result;
    int i, j ;
    while (scanf("%d%d", &m, &n) != EOF)
    {
        for (i = 0; i < m; i++)
        {
            for (j = 0; j < n; j++)
            {
                scanf("%d", &a[i][j]);
            }
        }
        result = abs((double)a[0][0]);
        x=0;
        y=0;    //假如只有一个人,那么不会进入循环,所以,这里必须做一次赋值
        s=a[0][0] ;
        for (i = 0; i < m; i++)
        {    
            for (j = 0; j < n; j++)        //这里的条件应该是 j            {
                if (result                {
                    result = abs((double)a[i][j]);
                    x = i;
                    y = j;
                    s = a[i][j];
                }
            }
        }
        cout << x + 1 << " " << y + 1 << " ";
        cout << s << endl;
    }
    return 0;
}


//做acm题目需要考虑全面,并不是说跟样例输出一样就正确了,很多边界条件是没有在输入样例中列举的,需要自己好好考虑。

//我刚才在杭电acm测试了,代码可以accepted