#include<stdio.h>
#include <stdlib.h>
/////////////////////////////////////
typedef struct
{
int vert;
int horiz;
}offsets;
offsets move[8] ={
{-1,0},
{-1,1},
{0,1},
{1,1},
{1,0},
{1,-1},
{0,-1},
{-1,-1}
};
/////////////////////////////////////
int MAX_COL,MAX_ROW;
int maze[MAX_COL][MAX_ROW]={ <--這裡怪怪的
1,1,1,1,1,1,1,1,
1,0,0,0,1,0,0,1,
1,1,1,0,1,1,0,1,
1,0,1,0,1,0,1,1,
1,0,1,0,1,0,1,1,
1,0,1,0,1,0,0,1,
1,1,1,1,1,1,1,1};
///////////////////////////////////////
void print_ans (void)
{
int i,j;
for(i=0;i<MAX_ROW;i++)printf("\n");
for(j=0;j<MAX_COL;j++)
printf("%6d",maze[i][j]);
printf("\n\n");
}
////////////////////////////////////////
void findpath(int row,int col)
{
int direct,next_row,next_col,k,l;
direct=0;
while(direct<8)
{
next_row=row+move[direct].vert;
next_col=col+move[direct].horiz;
if(maze[next_row][next_col]==0)
{
maze[next_row][next_col]=2;
if(next_row==MAX_ROW && next_col==MAX_COL)
print_ans();
else
findpath(next_row,next_col);
maze[next_row][next_col]=0;
}
direct++;
}
}
//////////////////////////////////////////////
void main ()
{
findpath(1,1);
system("PAUSE");
}
//////////////////////////////////////////////程式結束
//////////////////////////////////////////////
--------------------Configuration: try003 - Win32 Debug--------------------
Compiling...
try003.cpp
C:\程設資料\try003\try003.cpp(21) : error C2057: expected constant expression
C:\程設資料\try003\try003.cpp(21) : error C2466: cannot allocate an array of constant size 0
C:\程設資料\try003\try003.cpp(21) : error C2057: expected constant expression
C:\程設資料\try003\try003.cpp(21) : error C2466: cannot allocate an array of constant size 0
C:\程設資料\try003\try003.cpp(21) : error C2087: '<Unknown>' : missing subscript
Error executing cl.exe.
try003.exe - 5 error(s), 0 warning(s)
//////////////////////////////////////////////
拜託拜託....幫幫小弟找出解決的辦法吧....
小弟弟....我感激不盡.....
--
[1;33m# [36m Origin [33m# [0;41m Moon Night-Star BBS [31;47m bbs.c-co.net [m
[1;33m# [35m Author [33m# [32m220.142.4.9 [m