fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Maze{
  5. int id_x;
  6. int id_y;
  7. int north;
  8. int east;
  9. int south;
  10. int west;
  11. };
  12.  
  13. void check_consistent(struct Maze *maze, int x, int y){
  14.  
  15. cout << maze[1][1].east; //這行編譯不過
  16.  
  17. }
  18.  
  19. int main()
  20. {
  21. int x,y,num;
  22. int i,check=0;
  23. cin >> y >> x;
  24. Maze maze[y+1][x+1];
  25.  
  26. for( i=0; i< x*y ;i++){
  27. cin >> num;
  28. maze[(i/x)+1][(i%x)+1].id_x = (i%x)+1;
  29. maze[(i/x)+1][(i%x)+1].id_y = (i/x)+1;
  30. maze[(i/x)+1][(i%x)+1].west = num%2;
  31. num = num / 2;
  32. maze[(i/x)+1][(i%x)+1].south = num%2;
  33. num = num / 2;
  34. maze[(i/x)+1][(i%x)+1].east = num%2;
  35. num = num / 2;
  36. maze[(i/x)+1][(i%x)+1].north = num%2;
  37. }
  38. check_consistent(maze, x, y);
  39.  
  40. return 0;
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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);
                                ^
stdout
Standard output is empty