作者devilbilly (Billy)
看板HCHS60309
標題踩地雷
時間Fri Jan 4 12:30:42 2008
基本上
我已經寫出來大概的模型了
但是我不能幫你寫
可是我可以給你一點提示
1.輸入
2.建立陣列
3.放置地雷
4.放數字
5.輸出
6.使用者介面
1.just cin &cout
2.create a row*column array
3.to put mines in the array, the best way I have thought of
,just follow the following steps:
******
******
000000
000000
you have to put the mines from the position of x[0] to x[number of your mine]
then you swap the position with any element int the array by random
which will be faster to create.
4.As you see, the graph above has four corner and the top row,bottom row,
left column, right column, and the last the inner matrix.
like this 122221
344445
344445
166661
the number 1 is the four corner,
the number 2 is the top row.
the number 3 is the left column
the number 5 is the right column
the number 6 is the bottom row.
the number 4 is the inner matrix.
then we discuss those different types of position.
like, if the left top corner is a mine,
then we seek if 2,3,4 is also a mine or not
if not then we add one to that value of position.
the following discuss is left to you as a exercise.
there is another faster way to put mine.tell you later.
5.the letout is as easy as a piece of cake.
6.Still working on it...make it can be playable.
--
我是帥哥B
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.126.5.95
→ hank52078:英文很好喔!! 01/04 12:41
→ devilbilly:卸卸 01/04 12:55
推 lichunism:假如說輸入 5*5格式3個地雷,然後分別輸入三個地雷座標 01/04 21:36
推 lichunism:然後把整個5*5的整張地圖畫出來,這樣嗎? 01/04 21:36
→ lichunism:這樣不是硬幹就好了?? 01/04 21:37
→ devilbilly:不懂你說的硬幹是啥意思 01/04 21:46
→ devilbilly:地雷座標隨機 01/04 21:47
推 lichunism:隨機出現地雷這應該不用說吧,然後假如說5*5的地圖 01/04 21:51
→ lichunism:先把5*5都變成0,隨機到放地雷變-1。然後開for 01/04 21:52
→ lichunism:在5*5裡面一個一個跑,只要不是-1,就寫八行,加總 01/04 21:53
→ lichunism:附近的地雷數,然後把該格變成數字,最後輸出的時候記得 01/04 21:53
→ lichunism:-1要輸出成*就完成了!! 01/04 21:54
推 lichunism:這樣就是硬幹,然後要注意的就是,如果是5*5的地圖 01/04 21:54
→ lichunism:要把地圖周圍的數字歸零,不然又時候會有怪事發生... 01/04 21:55
→ devilbilly:我說的方法就是這樣 這樣算硬幹媽..只要 01/04 22:02
→ devilbilly:你判斷IF(I >=0 && J >=0)然後寫八行 01/04 22:02
→ devilbilly:有軟幹的方法媽 01/04 22:03