----------------解决方案--------------------------------------------------------
不好意思.心有余而力不足..
----------------解决方案--------------------------------------------------------
冒任顶替
----------------解决方案--------------------------------------------------------
nothing
[此贴子已经被作者于2006-3-26 19:03:11编辑过]
----------------解决方案--------------------------------------------------------
他冒任就冒任呗
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
楼主怎么还没给我金币,还想不想混了
----------------解决方案--------------------------------------------------------
有难度 不懂
----------------解决方案--------------------------------------------------------
我以前也写过一个,虽然实现了但是整个感觉好乱..
#include "stdio.h"
#include "stdlib.h"
#define col 10
#define row 10
#define nodes 100
int map[col][row]={1,1,1,1,1,1,1,1,1,1,
1,0,0,1,0,0,0,1,0,1,
1,0,0,1,0,0,0,1,0,1,
1,0,0,0,0,0,1,0,0,1,
1,0,1,1,1,0,0,0,0,1,
1,0,0,0,1,0,0,0,0,1,
1,0,1,0,0,0,1,0,0,1,
1,0,1,1,1,0,1,1,0,1,
1,1,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1,};
typedef struct
{
int x,y;
int dir;
}seater;
typedef struct
{
seater seat[nodes];
int top;
}stack;
seater strpos,endpos,curpos;
stack *router;
void init();
int pass();
void printfoot();
void push();
void nextstep();
void changedir();
void roadprint();
void pop();
void main()
{
init();
do
{
if(pass())
{
printfoot();
push();
nextstep();
}
else
{
curpos=router->seat[router->top];
if(curpos.dir<4)
changedir();
else
pop();
}
if((curpos.x==endpos.x)&&(curpos.y==endpos.y))
{
printf("you get!!\n");
break;
}
}while(router->top>=0);
roadprint();
}
void init ()
{
router=(stack *)malloc(sizeof(stack));
strpos.x=1;
strpos.y=1;
endpos.x=8;
endpos.y=8;
strpos.dir=1;
router->top=-1;
curpos=strpos;
}
int pass()
{
if(map[curpos.x][curpos.y]==0)
return 1;
else
return 0;
}
void printfoot()
{
map[curpos.x][curpos.y]=2;
}
void push()
{
router->top++;
router->seat[router->top]=curpos;
}
void nextstep()
{
curpos=router->seat[router->top];
curpos.y++;
curpos.dir=1;
}
void changedir()
{
router->seat[router->top].dir++;
switch(curpos.dir)
{
case 1:curpos.x++;break;
case 2:curpos.y--;break;
case 3:curpos.x--;break;
case 4:pop();break;
default :printf("error direction!\n");
}
curpos.dir=1;
}
void pop()
{
router->seat[router->top--];
curpos=router->seat[router->top];
changedir();
}
void roadprint()
{
for(int i=0;i<=router->top;i++)
{
printf("seat:%d,%d dir:%d top%d\n",router->seat[i].x,router->seat[i].y,router->seat[i].dir,router->top);
}
}
----------------解决方案--------------------------------------------------------