#include<iostream>#include<ctime>#include<cmath>using namespace std;char map[11][11];int i,y=9,x=1;void randomaisle(int y, int x){ map[y][x] = '0'; srand(time(0)); if(y!= 0 || x!= 10||x!=0||y!=10) { i=rand() % 4; switch (i) { case 0: randomaisle(y + 1,x); break; case 1: randomaisle(y,x + 1); break; case 2: randomaisle(y - 1,x); break; case 3: randomaisle(y,x - 1); break; } }}void createmap(){ for (int _y = 0; _y < 11; _y++) for (int _x = 0; _x < 11; _x++) map[_y][_x] = '#'; map[10][1] = '0'; randomaisle(y,x);}void showmap(){ for (int _y2 = 0; _y2 < 11; _y2++) { { for (int _x2 = 0; _x2 < 11; _x2++) cout << map[_y2][_x2]; } cout << "" << endl; }}int main(){ createmap(); showmap(); system("pause");}0是通道 #是墙 试了几次 是randomaisle(int y, int x) 递归那块有问题,但不知如何改..
目前暂无任何回答
- 0 回答
- 0 关注
- 1290 浏览
添加回答
举报
0/150
提交
取消