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
#include<iostream>
#include<fstream>
#include<cstdlib>
#include"mouse.h"
using namespace std;

int main(){
for(int i=0;i<10;i++){
for(int j=0;j<12;j++){
maze[i][j]=1;
}
}
char continu='Y';
int* startRow1=NULL;
int* startCol1=NULL;
startRow1=(int* )malloc (sizeof (int));
startCol1=(int* )malloc (sizeof (int));
maze[1][1]=0,maze[1][2]=0,maze[1][3]=0,maze[1][6]=0,maze[1][8]=0,maze[1][10]=0;
maze[2][3]=0,maze[2][5]=0,maze[2][6]=0,maze[2][7]=0,maze[2][8]=0,maze[2][9]=0,maze[2][10]=0;
maze[3][2]=0,maze[3][3]=0,maze[3][4]=0,maze[3][5]=0,maze[3][10]=0;
maze[4][2]=0,maze[4][10]=0,maze[4][11]=0;
maze[5][2]=0,maze[5][4]=0;
maze[6][2]=0,maze[6][3]=0,maze[6][4]=0;
maze[7][4]=0,maze[7][8]=0,maze[7][10]=0;
maze[8][2]=0,maze[8][3]=0,maze[8][4]=0,maze[8][5]=0,maze[8][6]=0,maze[8][8]=0,maze[8][9]=0,maze[8][10]=0;

for(int k=0;k<10;k++){
for(int m=0;m<12;m++){
if(k==4&&m==11){
cout<<maze[k][m]<<" Exit";
}
else{
cout<<maze[k][m];
}
}
cout<<endl;
}

currentSpot.rowPtr=(int* )malloc (sizeof (int));
currentSpot.colPtr=(int* )malloc (sizeof (int));
currentSpot.choice=0;
int startRow;
int startCol;
while(continu=='Y'){
direction='I';
visitStack=createStack();
alterStack=createStack();
cout<<"Enter the starting Position of row"<<endl;
cin>>startRow;
cout<<"Enter the starting Position of col"<<endl;
cin>>startCol;
*currentSpot.rowPtr=(startRow)-1;
*currentSpot.colPtr=(startCol)-1;
cout<<"("<<startRow<<","<<startCol<<")->";
*startRow1=startRow-1;
*startCol1=startCol-1;
pushStack(visitStack,startRow1,startCol1,0);
while(!isTerminate(currentSpot)&&visitStack->count!=0){
run(currentSpot);
}
if(isTerminate(currentSpot)){
cout<<"Succeed"<<endl<<endl;;
}
else{
cout<<"GAME OVER!"<<endl<<endl;
}
destoryStack(visitStack);
destoryStack(alterStack);
cout<<"Do you want to try again? Please Enter Y/N."<<endl;
cin>>continu;
}
return 0;
}