#include <iostream>
using namespace std;
struct Maze{
int id_x;
int id_y;
int north;
int east;
int south;
int west;
};
void check_consistent(struct Maze *maze, int x, int y){
cout << maze[1][1].east; //這行編譯不過
}
int main()
{
int x,y,num;
int i,check=0;
cin >> y >> x;
Maze maze[y+1][x+1];
for( i=0; i< x*y ;i++){
cin >> num;
maze[(i/x)+1][(i%x)+1].id_x = (i%x)+1;
maze[(i/x)+1][(i%x)+1].id_y = (i/x)+1;
maze[(i/x)+1][(i%x)+1].west = num%2;
num = num / 2;
maze[(i/x)+1][(i%x)+1].south = num%2;
num = num / 2;
maze[(i/x)+1][(i%x)+1].east = num%2;
num = num / 2;
maze[(i/x)+1][(i%x)+1].north = num%2;
}
check_consistent(maze, x, y);
return 0;
}
prog.cpp: In function ‘void check_consistent(Maze*, int, int)’:
prog.cpp:15:20: error: no match for ‘operator[]’ (operand types are ‘Maze’ and ‘int’)
cout << maze[1][1].east; //這行編譯不過
^
prog.cpp: In function ‘int main()’:
prog.cpp:38:32: error: cannot convert ‘Maze (*)[(x + 1)]’ to ‘Maze*’ for argument ‘1’ to ‘void check_consistent(Maze*, int, int)’
check_consistent(maze, x, y);
^