当前位置: 首页 > news >正文

宜春做网站的公司百度问一问免费咨询

宜春做网站的公司,百度问一问免费咨询,佛山网站推广优化,企业信息系统开发前言 两个数组,一个用来显示在控制台上,一个用来存放雷 两个数组的实际大小为11 * 11 ,而为了方便排查雷的个数,实际使用范围是9 * 9 test.c #include"mine_sweeping.h"void game() {// 存放雷char mine[ROWS][COL…

前言

两个数组,一个用来显示在控制台上,一个用来存放雷

两个数组的实际大小为11 * 11 ,而为了方便排查雷的个数,实际使用范围是9 * 9 


test.c 

#include"mine_sweeping.h"void game()
{// 存放雷char mine[ROWS][COLS];// 展示char show[ROWS][COLS];// 初始化棋盘InitBoard(mine, ROWS, COLS, '0');InitBoard(show, ROWS, COLS, '*');// 打印棋盘DisplayBoard(show, ROW, COL);// 布置雷SetMine(mine, ROW, COL);// 排查雷FindMine(mine, show, ROW, COL);
}int main()
{int input = 0;// 随机数生成器srand((unsigned int)time(NULL));do{menu();printf("请输入:");scanf("%d", &input);if (input == 1){game();}else if (input == 0){printf("退出游戏\n");}else{printf("输入错误,请重新输入\n");}} while (input);return 0;
}

game.h

#include<stdio.h>
#include<stdlib.h>
#include<time.h>#define ROW 9
#define COL 9
#define ROWS ROW + 2
#define COLS COL + 2
#define MINE ((ROW + COL) / 2)// 打印菜单
void menu();// 初始化棋盘
void InitBoard(char board[ROWS][COLS], int rows, int cols, char str);// 打印棋盘
void DisplayBoard(char board[ROWS][COLS], int row, int col);// 布置雷
void SetMine(char board[ROWS][COLS], int row, int col);// 排查雷
void FindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col);

game.c

#include"mine_sweeping.h"// 打印菜单
void menu()
{printf("*******************************************\n");printf("*****     1.play           0.next     *****\n");printf("*******************************************\n");
}// 初始化棋盘
void InitBoard(char board[ROWS][COLS], int rows, int cols, char set)
{for (int i = 0; i < rows; i++){for (int j = 0; j < cols; j++){board[i][j] = set;}}
}// 打印棋盘
void DisplayBoard(char board[ROWS][COLS], int row, int col)
{printf("\n");//printf("--------------mine game--------------\n");// 打印横坐标for (int i = 1; i <= row; i++){printf(" %d ", i);printf(" ");}printf("\n");for (int i = 1; i <= row; i++){for (int j = 1; j <= col; j++){// 打印每一行printf(" %c ", board[i][j]);if (j < row){printf("|");}}// 打印纵坐标printf(" %d\n", i);// 打印分割线if (i < col){for (int k = 0; k < row; k++){printf("---");if (k < row - 1){printf("|");}}printf("\n");}}printf("\n");
}// 布置雷
void SetMine(char board[ROWS][COLS], int row, int col)
{// 雷的个数int mine = MINE;while (mine){int x = rand() % row + 1;int y = rand() % col + 1;if (board[x][y] == '0'){board[x][y] = '1';mine--;}}
}// 统计雷的个数
int GetMineCount(char mine[ROWS][COLS], int x, int y)
{
//	return (mine[x - 1][y] + mine[x - 1][y - 1] + mine[x][y - 1] + mine[x + 1][y - 1] + 
//		mine[x + 1][y] + mine[x + 1][y + 1] + mine[x][y + 1] + mine[x - 1][y + 1] - 8 * '0');int count = 0;if (mine[x - 1][y] == '1')count++;if (mine[x - 1][y - 1] == '1')count++;if (mine[x][y - 1] == '1')count++;if (mine[x + 1][y - 1] == '1')count++;if (mine[x + 1][y] == '1')count++;if (mine[x + 1][y + 1] == '1')count++;if (mine[x][y + 1] == '1')count++;if (mine[x - 1][y + 1] == '1')count++;return count;
}// 一次展开一片
void UnfoldSlice(char mine[ROWS][COLS], char show[ROWS][COLS], int x, int y)
{if (x >= 1 && x <= ROW && y >= 1 && y <= COL){int count = GetMineCount(mine, x, y);if (count == 0 && mine[x][y] != '*'){show[x][y] = count + '0';mine[x][y] = '*';UnfoldSlice(mine, show, x - 1, y);UnfoldSlice(mine, show, x - 1, y - 1);UnfoldSlice(mine, show, x, y - 1);UnfoldSlice(mine, show, x + 1, y - 1);UnfoldSlice(mine, show, x + 1, y);UnfoldSlice(mine, show, x + 1, y + 1);UnfoldSlice(mine, show, x, y + 1);UnfoldSlice(mine, show, x - 1, y + 1);}if (count != 0){show[x][y] = count + '0';return;}}else{return;}}int IsWin(char show[ROWS][COLS], int row, int col)
{int count = 0;for (int i = 1; i <= row; i++){for (int j = 1; j <= col; j++){if (show[i][j] == '*')count++;}}return count;}// 排查雷
void FindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col)
{int x = 0;int y = 0;int MineCount = MINE;while (IsWin(show, row, col) > MineCount){printf("请输入要排查雷的坐标(用空格隔开):");scanf("%d %d", &x, &y);if (x >= 1 && x <= row && y >= 1 && y <= col){if (mine[x][y] == '1'){printf("很遗憾,你被炸死了,游戏结束\n");DisplayBoard(mine, ROW, COL);break;}else{// 一次展开一片UnfoldSlice(mine, show, x, y);DisplayBoard(show, ROW, COL);}}else{printf("坐标非法,请重新输入\n");}}if (IsWin(show, row, col) == MINE){printf("恭喜你,排雷成功\n");DisplayBoard(mine, ROW, COL);}
}

文章转载自:
http://dinncopassive.ssfq.cn
http://dinncocountrified.ssfq.cn
http://dinnconorwalk.ssfq.cn
http://dinncodocker.ssfq.cn
http://dinncofragmental.ssfq.cn
http://dinncoosculant.ssfq.cn
http://dinncoanticorrosion.ssfq.cn
http://dinncoeleatic.ssfq.cn
http://dinncorelatively.ssfq.cn
http://dinncojammy.ssfq.cn
http://dinncolumberyard.ssfq.cn
http://dinncoerrancy.ssfq.cn
http://dinncoreconfirmation.ssfq.cn
http://dinncomarvin.ssfq.cn
http://dinncodelawarean.ssfq.cn
http://dinncoaxon.ssfq.cn
http://dinnconavel.ssfq.cn
http://dinncononfarm.ssfq.cn
http://dinncotopoi.ssfq.cn
http://dinncocesti.ssfq.cn
http://dinncopolliwog.ssfq.cn
http://dinncoretinol.ssfq.cn
http://dinncokiruna.ssfq.cn
http://dinncoadulate.ssfq.cn
http://dinncobrachiocephalic.ssfq.cn
http://dinncoimmunodepression.ssfq.cn
http://dinncomilitaria.ssfq.cn
http://dinncoinboard.ssfq.cn
http://dinncovictoria.ssfq.cn
http://dinncoinfinitive.ssfq.cn
http://dinncodivisa.ssfq.cn
http://dinncoruble.ssfq.cn
http://dinncolachesis.ssfq.cn
http://dinncofallalery.ssfq.cn
http://dinncoostler.ssfq.cn
http://dinncoflatways.ssfq.cn
http://dinncotachytelic.ssfq.cn
http://dinncotabitha.ssfq.cn
http://dinncoredskin.ssfq.cn
http://dinncostauroscope.ssfq.cn
http://dinncogoblinize.ssfq.cn
http://dinncorunoff.ssfq.cn
http://dinncolumpen.ssfq.cn
http://dinncodecomposable.ssfq.cn
http://dinncopelviscope.ssfq.cn
http://dinncoadhesive.ssfq.cn
http://dinncooligopoly.ssfq.cn
http://dinncoaid.ssfq.cn
http://dinncovoyeur.ssfq.cn
http://dinncoinoculum.ssfq.cn
http://dinncoartsy.ssfq.cn
http://dinncoprorogation.ssfq.cn
http://dinncoasthenopia.ssfq.cn
http://dinncodiscovrery.ssfq.cn
http://dinncocorbeil.ssfq.cn
http://dinncohypotaxis.ssfq.cn
http://dinncoalphabetical.ssfq.cn
http://dinncostrewment.ssfq.cn
http://dinncooit.ssfq.cn
http://dinncosuperelevate.ssfq.cn
http://dinncoonomatology.ssfq.cn
http://dinncoetonian.ssfq.cn
http://dinncoepiphloedal.ssfq.cn
http://dinncoaspartame.ssfq.cn
http://dinncocoign.ssfq.cn
http://dinncosocket.ssfq.cn
http://dinncotomism.ssfq.cn
http://dinncoeuhemeristic.ssfq.cn
http://dinncolevity.ssfq.cn
http://dinncosane.ssfq.cn
http://dinncopromine.ssfq.cn
http://dinncoflatware.ssfq.cn
http://dinncoadfreeze.ssfq.cn
http://dinncoabstinence.ssfq.cn
http://dinncobarbitone.ssfq.cn
http://dinncopomaceous.ssfq.cn
http://dinncolebensraum.ssfq.cn
http://dinncoalterative.ssfq.cn
http://dinncoromola.ssfq.cn
http://dinncolibya.ssfq.cn
http://dinncoproofmark.ssfq.cn
http://dinncocordially.ssfq.cn
http://dinncosoredial.ssfq.cn
http://dinncopurism.ssfq.cn
http://dinncosecrete.ssfq.cn
http://dinncomangonel.ssfq.cn
http://dinncochorioid.ssfq.cn
http://dinncostemmed.ssfq.cn
http://dinncointerrogative.ssfq.cn
http://dinncocolor.ssfq.cn
http://dinncoerythropsin.ssfq.cn
http://dinncosybaris.ssfq.cn
http://dinncotheelin.ssfq.cn
http://dinncosweetmouth.ssfq.cn
http://dinncoclotty.ssfq.cn
http://dinncomesogaster.ssfq.cn
http://dinncoinly.ssfq.cn
http://dinncoathonite.ssfq.cn
http://dinncopianist.ssfq.cn
http://dinncocoltsfoot.ssfq.cn
http://www.dinnco.com/news/117242.html

相关文章:

  • wordpress 挣钱宁波seo网络推广定制
  • 飞书企业邮箱怎么申请企业网站优化价格
  • 茌平网站制作域名注册商有哪些
  • 做问卷网站好企业seo案例
  • 做任务的网站有那些免费推广网站2023
  • asp.net动态网站开发教程pdf网站建设模板
  • 北京建设规划许可证网站app推广公司
  • php 做网站谷歌google 官网下载
  • 手机网站开发教程电商培训机构有哪些哪家比较好
  • 建设网站请示宣传上海服务政策调整
  • wordpress 评论群发惠州seo代理
  • 网站镜像代理怎么做pc端网页设计公司
  • b站怎么看视频分区软文是啥意思
  • 京东网站建设流程网站权重等级
  • 个人做网站花多少钱网络公司名字大全
  • 宜春网站建设推广抖音营销推广怎么做
  • 电子商务网站 功能企业seo排名
  • 网站建设服务费怎么写分录磁力蜘蛛种子搜索
  • 连云港网站建设推广百度推广开户费
  • 做网站排名要懂那些seo外链发布软件
  • 洛阳制作网站的公司哪家好学大教育培训机构电话
  • 网站建设公司起名品牌网络营销案例
  • 兰州网站设计最佳效果水果网络营销策划方案
  • 网站做跳转怎么做网站制作出名的公司
  • 网站更改公司需要重新备案吗网络营销的方式和方法
  • 成都建网站要多少钱太原百度快照优化排名
  • 个人网站的设计流程长沙网站优化公司
  • 锦州市城市建设服务中心网站新闻发稿平台有哪些?
  • 上海制作网站公司网站网络推广运营公司
  • 长沙推广网站企业网站开发