Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <wchar.h>
- #include <locale.h>
- #include <stdlib.h>
- #include <time.h>
- int fy[500][500];
- int d[][2] = {{0, 1},{1, 0},{0, -1},{-1, 0}};
- wchar_t yzfy[]= {L' ',L'┃',L'━',L'┛',L'┃',L'┃',L'┓',L'┫',
- L'━',L'┗',L'━',L'┻',L'┏',L'┣',L'┳',L'╋'};
- const int w=35, h=20, rw = w+2, rh = h+2;
- int dfs(int y, int x)
- {
- if (fy[y][x])
- return 0;
- else
- fy[y][x] |= 0x10;
- for (int f=rand()%4, i=0, p=rand()&1?3:1, u,v; i<4; ++i,f=(f+p)%4)
- if (dfs(v=y+d[f][0], u=x+d[f][1]))
- fy[y][x] |= 1<<f, fy[v][u] |= (1<<((f+2)%4));
- return 1;
- }
- int main()
- {
- setlocale(LC_ALL, "");
- for (int y=0; y<rh; ++y) fy[y][0]|=10, fy[y][rw-1]|=10;
- for (int x=0; x<rw; ++x) fy[0][x]|=5, fy[rh-1][x]|=5;
- srand(time(NULL));
- dfs(w/2,h/2);
- fy[1][1] |= 12;
- fy[rh-2][rw-2] |= 3;
- for (int y=1; y<rh; ++y,putwchar(L'\n'))
- for (int x=1; x<rw; ++x)
- putwchar(yzfy[15^((fy[y-1][x-1]&3)|(fy[y][x]&12))]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment