標頭檔案
#ifndef __mine_h__
#define __mine_h__
#define line 10
#define list 10
#define rows 6
#define cows 6
int game(char userboard[line+2][list+2], char playerboard[line][list]);
void printboard(char playerboard[line][list]);
void minelay(char userboard[line + 2][list + 2]);
void printuser(char userboard[line + 2][list + 2]);
int mineclear(char userboard[line + 2][list + 2], char playerboard[line][list]);
void blast(char userboard[line + 2][list + 2], char playerboard[line][list]);
int counter(char userboard[line + 2][list + 2], char playerboard[line][list], int x, int y);
#endif
函式檔案
#define _crt_secure_no_warnings 1
#include#include#include#include#include#include"mine.h"
void minelay(char userboard[line + 2][list + 2])
else
j = 20;
while (i < j) }
}void blast(char userboard[line + 2][list + 2], char playerboard[line][list])//全域性輸了
if ('*' == playerboard[i - 1][j - 1]) //
//} }
}void printboard(char playerboard[line][list])
printf("\n");
} printf("\n");
}int mineclear(char userboard[line + 2][list + 2], char playerboard[line][list])
if ('0' == userboard[x][y])
}for (i = x; i >= 1; i--,j = y)//向上向右數
}for (m = x; m <= line; m++,n = y)//向下向左
}for (p = x; p <= line; p++,q = y)//向下向右
}printboard(playerboard);
//printuser(userboard);
win = 0; //一開始的時候這個地方沒有寫win = 0;這樣就出現了乙個問題,就是,上次輸入乙個座標迴圈的時候win已經有大於0的值,導致迴圈完的最終結果不能小於3
for (x = 0; x < line; x++)
}if (win <= 3)
}printf("掃雷成功,你贏了!!!\n");
return 0;}}
} }}int counter(char userboard[line + 2][list + 2], char playerboard[line][list], int x, int y)
else
return num;
}int game(char userboard[line+2][list+2], char playerboard[line][list])
void printuser(char userboard[line + 2][list + 2])
printf("\n");
} printf("\n");
}
測試函式檔案
#define _crt_secure_no_warnings 1
#include#include#include#include#include#include"mine.h"
//1.第一次掃雷,掃一大片2.玩家選擇難度3.插標記
void menu()
int main()
if (0 == input)
}printf("遊戲結束,歡迎再次使用!!!\n");
system("pause");
return 0;
}
C語言 掃雷遊戲
要求 1 第一下輸入座標,不炸死。2 座標周圍沒有雷,可以實現展開。思想 一 用乙個測試函式test 完成使用者的整個遊戲體驗,放在主函式中。二 test 函式中應該完成的內容 選單選擇和遊戲部分。選單選擇即menu 函式 遊戲部分即game 函式 因為是遊戲,所以以使用者體驗為先,先讓使用者玩一把...
掃雷遊戲C語言
掃雷遊戲c語言 include include include define max row 9 define max col 9 define max mine count 10 char mine map max row max col 雷的位置 char show map max row ma...
C語言 掃雷遊戲
簡單描述 輸入要要掃的位置.如果是雷,則遊戲失敗.如果將所有不是雷的位置都掃了一遍,則遊戲勝利.主要細節 初始化 玩家掃雷圖,地雷布局圖 for int row 0 row row row for int row 0 row row row int count 0 while count 列印地圖 ...