| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1430 人关注过本帖
标题:求助!谁能帮解迷宫,给1000金币,来者皆有
只看楼主 加入收藏
梦想中国
Rank: 2
等 级:新手上路
威 望:5
帖 子:539
专家分:0
注 册:2006-2-26
收藏
得分:0 
谢谢楼上,不过这年头拼的就是实力,要的就是速度

2006-03-26 17:25
末日恋人
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-3-21
收藏
得分:0 
不好意思.心有余而力不足..

2006-03-26 18:00
sunnvya
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:1094
专家分:0
注 册:2005-11-23
收藏
得分:0 
冒任顶替

http://www. 第二站>>>提供源码下载
2006-03-26 18:42
未来的梦
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2006-3-23
收藏
得分:0 

nothing

[此贴子已经被作者于2006-3-26 19:03:11编辑过]


QQ: 619969970.weilai.虽无飞,飞必冲天;虽无鸣,鸣必惊人;虽无想,想则必成。
2006-03-26 18:53
未来的梦
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2006-3-23
收藏
得分:0 
他冒任就冒任呗

QQ: 619969970.weilai.虽无飞,飞必冲天;虽无鸣,鸣必惊人;虽无想,想则必成。
2006-03-26 18:55
haishanglang
Rank: 1
等 级:新手上路
帖 子:378
专家分:0
注 册:2006-3-2
收藏
得分:0 

2006-03-26 19:17
success
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-3-24
收藏
得分:0 
楼主怎么还没给我金币,还想不想混了

2006-03-26 22:33
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 
有难度 不懂
2006-03-27 01:28
farmerbee
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2006-2-27
收藏
得分:0 
我以前也写过一个,虽然实现了但是整个感觉好乱..
#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);
}
}

2006-03-27 12:08
快速回复:求助!谁能帮解迷宫,给1000金币,来者皆有
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022215 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved