/* 3xn grid walks starting in the lower left corner.*/ /* Chad Brewbaker 2-18-2003 Current output is: 1,3,8,17,38,78,164,333,680,1368,2768,5552,11204,22369 VS NJAS 1,3,8,17,38,78,164,332,680,1368,2768,5552,11168,22368 */ #include #define UP '^' #define RIGHT '>' #define DOWN 'v' #define LEFT '<' #define EMPTY '#' /* SAMPLE GRID: v < < < < < < < < v < v < > > > > > > > # ^ < ^ < ^ > > > > > > > > > > > > ^ */ char GRID[3][20]; int COLS; int PATH_NUM; void printPath() { int i,j; cout <<"\n"; for(i=2;i>=0;i--) { cout <<"\n"; for( j=0;j0) { if(GRID[y-1][x]==EMPTY) { GRID[y][x]=DOWN; pathSearch(y-1,x,length+1); GRID[y][x]=EMPTY; } } //LEFT if(x>0) { if(GRID[y][x-1]==EMPTY) { GRID[y][x]=LEFT; pathSearch(y,x-1,length+1); GRID[y][x]=EMPTY; } } return; } int main() { int i,j; cout << "\nHow many colums do you want?\n"; cin >> COLS; if(COLS>20 || COLS<1) { cout << "\nNeed 1-20 for your column numbers\n"; return 1; } for(i=0;i<3;i++) { for(j=0;j