1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
#include <iostream>
using namespace std;
const int SIZE = 12;
char maze[SIZE][SIZE]={
{'#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','.','.','.','#','.','.','.','.','.','.','#'},
{'.','.','#','.','#','.','#','#','#','#','.','#'},
{'#','#','#','.','#','.','.','.','.','#','.','#'},
{'#','.','.','.','.','#','#','#','.','#','.','.'},
{'#','#','#','#','.','#','.','#','.','#','.','#'},
{'#','.','.','#','.','#','.','#','.','#','.','#'},
{'#','#','.','#','.','#','.','#','.','#','.','#'},
{'#','.','.','.','.','.','.','.','.','#','.','#'},
{'#','#','#','#','#','#','.','#','#','#','.','#'},
{'#','.','.','.','.','.','.','#','.','.','.','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#'},
};
bool checkpath(int X, int Y){
//turn west
if(maze[X][Y-1]=='.'){
return true;}
//turn north
if(maze[X][Y-1]!='.' && maze[X+1][Y]!='.' && maze[X][Y+1]!='.' && maze[X-1][Y]=='.'){
return true;}
//turn south
if(maze[X][Y-1]!='.' && maze[X+1][Y]=='.'){
return true;}
//turn east
if(maze[X][Y-1]!='.' && maze[X+1][Y]!='.' && maze[X][Y+1]=='.'){
return true;}
}
int findpath(int x, int y){
//turn west
if(maze[x][y-1]=='.'){
return 1;}
//turn north
if(maze[x][y-1]!='.' && maze[x+1][y]!='.' && maze[x][y+1]!='.' && maze[x-1][y]=='.'){
return 2;}
//turn south
if(maze[x][y-1]!='.' && maze[x+1][y]=='.'){
return 3;}
//turn east
if(maze[x][y-1]!='.' && maze[x+1][y]!='.' && maze[x][y+1]=='.'){
return 4;}
}
int main(){
int startX = 2;
int startY = 0;
int endX = 4;
int endY = 11;
int i,j;
bool checkpath;
int findpath;
while(startX<=endX && startY<=endY){
// 21 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(startX>0 && checkpath(startX, startY)==true){ //Error 1 error C2064: term does not evaluate to a function taking 2 arguments
// 22 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(findpath(startX , startY)==1){ //Error 2 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY-=1;
}// 23 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==2){ //Error 3 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX-=1;
}// 24 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==3){ //Error 4 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX+=1;
}// 25 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==4){ //Error 5 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY+=1;
}
}// 26 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(startX<13 && checkpath(startX, startY)==true){ //Error 6 error C2064: term does not evaluate to a function taking 2 arguments
// 27 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(findpath(startX , startY)==1){ //Error 7 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY-=1;
}// 28 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==2){ //Error 8 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX-=1;
}// 29 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==3){ //Error 9 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX+=1;
}// 30 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==4){ //Error 10 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY+=1;
}
}// 31 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(startY>0 && checkpath(startX, startY)==true){ //Error 11 error C2064: term does not evaluate to a function taking 2 arguments
// 32 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(findpath(startX , startY)==1){ //Error 12 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY-=1;
}// 33 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==2){ //Error 13 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX-=1;
}// 34 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==3){ //Error 14 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX+=1;
}// 35 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==4){ //Error 15 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY+=1;
}
}// 36 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(startY<13 && checkpath(startX, startY)==true){ //Error 16 error C2064: term does not evaluate to a function taking 2 arguments
// 37 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
if(findpath(startX , startY)==1){ //Error 17 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY-=1;
}// 38 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==2){ //Error 18 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX-=1;
}// 39 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==3){ //Error 19 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startX+=1;
}// 40 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
else if(findpath(startX , startY)==4){ //Error 20 error C2064: term does not evaluate to a function taking 2 arguments
maze[startX][startY]='X';
cout << maze[startX][startY];
startY+=1;
}
}
}
system("Pause");
}
|