该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
char cw[][4]={" ","┃","━","┗","┃","┃","┏","┣","━"//map
,"┛","━","┻","┓","┫","┳" ,"╋"};char m[50][50];char *getw
(int x,int y){return cw[(m[x] [y-1]?0:1)|(m[x+1][y]?0:2)|(m [
x][y+1]?0:4)|(m[x-1][y]?0:8) ];}int sr(int x,int y){ static
int d[4][2]={{0,1},{1,0},{0 ,-1},{-1,0}};int zx=x*2,zy=y*
2,nx,tn=rand()%2? 1:3,i;m[ zx][zy]=1;for(i=0,nx=rand()%
4;i<4;i++,nx=(nx+tn)%4)if (m[zx+2*d[nx][0]][zy+2*d[nx
][1]]==0)m[zx+d[nx][0]][ zy+d[nx][1]]=1,sr (x+d[nx]
[0],y+d[nx][1]); return 0;} void Make_Maze(int x,
int y){int z1,z2;for ( z1=0,z2=2*y+2;z1<=2*x+2;
z1++)m[z1][0]=1,m[z1] [z2]=1;for(z1=0, z2=2*x
+2;z1<=2*y+2;z1++)m[ 0][z1]=1,m[z2][z1]=1;m
[1][2]=1;m[2*x+1][2 *y]=1;srand((unsigned
)time(NULL) ); sr( rand()%x+1,rand()%y+
1);}int main(void ){int x=15,y=10,z1,
z2;Make_Maze(x,y );for(z2=1;z2<=y*2
+1;z2++){for(z1 =1;z1<=x*2+1;z1++
)printf(m[z1][ z2]?" ":getw(z1
,z2));if(z2<= y*2)putchar(10)
;}return 0;} // Puzzle Game
插一下楼