夷希微
|
分享:
▲
▼
Re:【求助】c++也能写迷宫吗?><"
呵呵~怎么可以说老师要整死你们呢~这个程式并不难的呀 ^^ 小妹来鸡婆一下,帮您画迷宫,不过走迷宫的程式您要自己写~嘻嘻 ^^y C 的写法如下: 复制程式
#include <stdio.h>
void main(void)
{
int MAP[8][8]={{1,0,1,1,1,1,1,1},
{1,0,1,0,1,0,0,1},
{1,0,1,0,1,0,1,1},
{1,0,1,0,0,0,0,1},
{1,0,0,0,1,1,0,1},
{1,0,1,0,0,1,0,1},
{1,0,1,0,1,1,0,1},
{1,1,1,1,1,1,2,1}};
int x,y;
for(x=0;x<8;x++)
{
for(y=0;y<8;y++)
{
if(MAP[x][y]==1)printf("■");
else printf(" ");
}
printf("\n");
}
} C++ 的写法如下: 复制程式
#include <iostream.h>
void main(void)
{
int MAP[8][8]={{1,0,1,1,1,1,1,1},
{1,0,1,0,1,0,0,1},
{1,0,1,0,1,0,1,1},
{1,0,1,0,0,0,0,1},
{1,0,0,0,1,1,0,1},
{1,0,1,0,0,1,0,1},
{1,0,1,0,1,1,0,1},
{1,1,1,1,1,1,2,1}};
int x,y;
for(x=0;x<8;x++)
{
for(y=0;y<8;y++)
{
if(MAP[x][y]==1)cout << "■";
else cout << " ";
}
cout << endl;
}
} 加油唷 ^_^
此文章被评分,最近评分记录财富:20 (by codeboy) | 理由: 夷希微小妹...请多多指教阿...感谢指导网友阿~^^ | |
|
|
|