代码拉取完成,页面将自动刷新
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include "game.h"
using namespace std;
void menu() {
cout << "**********************************" << endl;
cout << "***1.play***0.exit**" << endl;
cout << "**********************************" << endl;
}
void game() {
char mine[ROWS][COLS] = { 0 };
char show[ROWS][COLS] = { 0 };
//1.初始化一个棋盘
intial_board(mine, ROWS, COLS,'0');
intial_board(show, ROWS, COLS, '*');
//2.打印棋盘
//3.布置雷
set_mine(mine, ROW, COL);
show_board(mine, ROW, COL);
show_board(show, ROW, COL);
//4.排雷了
find_mine(mine, show, ROW, COL);
}
int main() {
int input;
srand((unsigned int)time(NULL));//这里调用一次就行了 设置随机数的生成起点 time函数会返回一个时间戳 这个会返回一个随机值 srand要求你要传入一个随机值
do {
menu();
cin >> input;
switch (input)
{
case 1 :
game();
break;
case 0:
cout << "退出游戏" << endl;
break;
default:
cout << "选择错误,请重新选择!!";
break;
}
} while (input);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。