#include "oestack.h" #include // including library using namespace std; #include class cell // class of cell { int row,column; int visited; int wallstatus; public: void addcell(int a,int b,int c) // which row, which column and also is it a wall, save this info. { row=a; column=b; wallstatus=c; visited=0; } void editvisit() //for checking. { visited=1; } int checkvisit() { return visited; } int checkwall() { return wallstatus; } int checkrow() { return row; } int checkcolumn() { return column; } }; class game:public cell { public: stack stackcell; //created a stack type of cell cell kop[5][5]; // created an array from cell object game() { int l,z,i; for(i=0; i<5; i++) // All cell is visited now, all of them is wall. { for(int k=0;k<5; k++) { kop[i][k].addcell(1,1,1); } } cout<<"Enter maze from left to right:"<>z; kop[j][l].addcell(l,j,z); //create } } for(i=0; i<5; i++) // write our maze to the screen { for(int k=0;k<5; k++) { cout< terstenyaz(9); // to write from last :) start = kop[i][k]; // start kop[i][k].editvisit(); // you visited where you start. stackcell.push(start); // put (1,1) (start place) to in your stack while (found == 0) // found 0 { if(kop[i][k].checkrow()==3 && kop[i][k].checkcolumn()==3) // if end of the maze { found =1; // find way to escape } else if(kop[i][k-1].checkwall() == 0 && kop[i][k-1].checkvisit() != 1) //check left , if not visited then go { k=k-1; kop[i][k].editvisit(); stackcell.push(kop[i][k]); } else if(kop[i+1][k].checkwall() == 0 && kop[i+1][k].checkvisit() != 1) //check below , if not visited then go { i=i+1; kop[i][k].editvisit(); stackcell.push(kop[i][k]); } else if(kop[i][k+1].checkwall() == 0 && kop[i][k+1].checkvisit() != 1) //check right , if not visited then go { k=k+1; kop[i][k].editvisit(); stackcell.push(kop[i][k]); } else if (kop[i][k].checkrow() == 1 && kop[i][k].checkcolumn()== 1) // if you go back to start then there is no escape from maze { cout<<"No escape from there"<