Académique Documents
Professionnel Documents
Culture Documents
============================================
#include <conio.h>
#include <string.h>
#include <iostream.h>
char GetChoice();
void GetDimensions(int& r, int& c);
void InputMaze(int r, int c, Maze& l);
void PathFinder(int r, int c, Maze& l, char mark, Boolean& found);
int main()
{
char choice = 'Y';
int rows;
int cols;
char flag = 'a';
GetDimensions(rows, cols);
int startRow = 1;
int startCol = 1;
PathFinder(startRow, startCol, lab, flag, pathFound);
if (pathFound)
{
cout << lab
<< endl;
}
else
{
cout << "NO PATH EXISTS!"<< endl;
}
choice = GetChoice();
}
return (1);
}
char GetChoice()
{
char ch;
cin.ignore(50, '\n');
return (ch);
}
{
cout << "Enter number of rows desired (MAX = 25): ";
cin >> r;
cout << "Enter number of columns desired (MAX = 25): ";
cin >> c;
cout << endl;
cin.ignore(50, '\n');
return;
}
{
cout << "Specify maze as "
<< r
<< " lines of "
<< c
<< " chars ('.' or '*'): "
<< endl;
cin >> l;
cout << endl;
return;
}
{
if (l.is_open(r, c))
{
l.mark(r, c, mark);
mark++;
if (mark > 'z')
mark = 'a';
if (c < l.max_col())
{
PathFinder(r, c+1, l, mark, found);
if (found)
return;
}
if (r < l.max_row())
{
PathFinder(r+1, c, l, mark, found);
if (found)
return;
}
if (c > 1)
{
PathFinder(r, c-1, l, mark, found);
if (found)
return;
}
if (r > 1)
{
PathFinder(r-1, c, l, mark, found);
if (found)
return;
}
l.unmark(r, c);
}
else
return;
}
http://www.ravianeducation.blogspot.com
FARHAN: 03008855006