#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 關注
- 1314 瀏覽
添加回答
舉報
0/150
提交
取消