夷希微
|
分享:
▲
▼
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) | 理由: 夷希微小妹...請多多指教阿...感謝指導網友阿~^^ | |
|
|
|