问题描述
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;}
如代码所示,求解
问题解答
回答1:要看你调用处传入的参数具体是什么,怎样构造的。你把调用处的代码也得贴出来啊。
回答2:对于二维数组第一个参数是可以不指定的,系统可以根据数组初始化时指定的总大小和第二维参数来得到第一维参数,你这个是个段错误,应该是你传所参数的空间大小的问题,空间太小了,以至于一维参数达不到3。