c++ 二维数组取值,报错 Signal: SIGSEGV (Segmentation fault)
大家讲道理
大家讲道理 2017-04-17 15:36:42
0
2
896
bool isLine(int map[][4]) {
    for (int i = 0; i < 4; i++) {

        for (int j = 0; j < 4; j++) {
            cout <<  map[i][j] << ' ' ;
        }
        cout<<endl;
    }
    if (map[3][0] * map[2][1]* map[1][2] * map[0][3] == 1) return 1;

//*
//*
//*执行到这行时报错,Signal: SIGSEGV (Segmentation fault)
//*
//*
    if (map[0][0] * map[1][1] * map[2][2] * map[3][3] == 1) return 1;


    for (int row = 0; row < 4; row++) {
        if (map[row][0] *map[row][1]* map[row][2]* map[row][3] == 1) return 1;
    }
    for (int col = 0; col < 4; col++) {
        if (map[0][col] * map[1][col]* map[2][col] * map[3][col]) return 1;
    }
    return 0;
}

如代码所示,求解

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
左手右手慢动作

It depends on the specific parameters passed in at the call point and how they are constructed. You have to post the calling code as well.

阿神

For a two-dimensional array, the first parameter does not need to be specified. The system can obtain the first-dimensional parameter based on the total size and the second-dimensional parameter specified when the array is initialized. This is a segfault. It should be the parameter you passed. There is a problem with the size of the parameter space. The space is too small, so that the one-dimensional parameter cannot reach 3.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template