首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > 其他 > 鼹鼠闯迷宫

鼹鼠闯迷宫

  • 资源大小:1.47 MB
  • 上传时间:2021-06-30
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: 算法 c 迷宫

资 源 简 介

资源描述void creatWay(int (*mg)[N],int x, int y)//在迷宫中产生一条路,使用图的深度遍历思想来实现, { static int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};////将要走的4个方向保存在二维数组中 int zx = x*2; int zy = y*2; int next, turn, i; mg[zx][zy] = 0; if(rand()%2) turn = 1; else turn = 3; for(i=0,next=rand()%4;i<4;i++,next=(next+turn)%4) if(mg[zx+2*dir[next][0]][zy+2*dir[next][1]] == 1) { mg[zx+dir[next][0]][zy+dir[next][1]] = 0; creatWay(mg,x+dir[next][0], y+dir[next][1]); } } void CreatMaze(int (*mg)[N],int x)//创建一个边长是2*x+3的迷宫,并设置好墙和路。 { int r,c; for(r=0; r<=x*2+2; ++r) for(c=0; c<=x*2+2; ++c) mg[r][c] = 1; for(r=0, c=2*x+2; r<=2*x+2; ++r) { mg[r][0] = 0; mg[r][c] = 0; } for(r=0, c=2*x+2; r<=2*x+2; ++r) { mg[0][r] = 0; mg[c][r] = 0; } mg[1][2] = 6; mg[

文 件 列 表

鼹鼠闯迷宫
鼹鼠闯迷宫.dsw
鼹鼠闯迷宫.ncb
鼹鼠闯迷宫.opt
迷宫
VIP VIP
0.201373s