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

个人网站备案 费用宁波seo快速优化平台

个人网站备案 费用,宁波seo快速优化平台,怎么宣传网站,备案 网站首页url云边有个稻草人-CSDN博客 在学完C语言函数之后,我们就有能力去实现简易版扫雷游戏了(成就感满满),下面是扫雷游戏的源码,快试一试效果如何吧! 在test.c里面进行扫雷游戏的测试,game.h和game.c…

云边有个稻草人-CSDN博客

在学完C语言函数之后,我们就有能力去实现简易版扫雷游戏了(成就感满满),下面是扫雷游戏的源码,快试一试效果如何吧!

在test.c里面进行扫雷游戏的测试,game.h和game.c里实现扫雷游戏的实现,后续我会出扫雷游戏代码的详细思路和解析

目录

效果图

game.h

game.c

test.c


效果图

(哇趣,一下子就踩到雷了,幸运到爆!)

game.h

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

game.c

#define _CRT_SECURE_NO_WARNINGS 1
#include "game.h"//初始化棋盘
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 show[ROWS][COLS], int row, int col)
{printf("--------扫雷--------\n");//打印显示列int i = 0;for ( i = 0; i <= row; i++){printf("%d ", i);}printf("\n");for (i = 1; i <= row; i++){int j = 0;printf("%d ", i);for (j = 1; j <= col; j++){printf("%c ", show[i][j]);}printf("\n");}}//布置雷
void SetMine(char mine[ROWS][COLS], int row, int col)
{//产生随机的一个坐标int x = 0;int y = 0;int count = EASY_COUNT;while (count){x = rand() % row + 1;y = rand() % col + 1;if (mine[x][y] != '1'){mine[x][y] = '1';count--;}}
}//方法一
//int GetMineCount(char mine[ROWS][COLS], int x, int y)
//{
//	return mine[x - 1][y] +
//	mine[x + 1][y] + 
//	mine[x - 1][y - 1] +
//	mine[x][y - 1] + 
//	mine[x + 1][y - 1] + 
//	mine[x - 1][y + 1] + 
//	mine[x][y + 1] + 
//	mine[x + 1][y + 1] - 8 * '0';
//}//方法二
int GetMineCount(char mine[ROWS][COLS], int x, int y)
{int i = 0;int count = 0;for (i = -1; i <= 1; i++){int j = 0;for (j = -1; j <= 1; j++){count += mine[x + i][y + j] - '0';}}return count;
}//排查雷
void FindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col)
{int x = 0;int y = 0;int win = 0;while (win<row*col-EASY_COUNT){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{int count = GetMineCount(mine, x, y);show[x][y] = count + '0';DisplayBoard(show, ROW, COL);win++;}}else{printf("输入错误,请重新输入:");}}if (win == EASY_COUNT){printf("恭喜你,排雷成功!\n");}}

test.c

#define _CRT_SECURE_NO_WARNINGS 1
#include"game.h"//打印菜单
void menu()
{printf("     欢迎来到扫雷游戏    \n");printf("*************************\n");printf("********* 1.play ********\n");printf("********* 0.exit ********\n");printf("*************************\n");
}void game()
{srand((unsigned int)time(NULL));//定义两个字符串数组char mine[ROWS][COLS] = { 0 };//存放雷的信息char show[ROWS][COLS] = { 0 };//存放排查出的雷的信息//初始化棋盘InitBoard(mine, ROWS, COLS, '0');InitBoard(show, ROWS, COLS, '*');//打印棋盘DisplayBoard(show, ROW, COL);//布置雷SetMine(mine, ROW, COL);//排查雷FindMine(mine, show, ROW, COL);}void test()
{int input = 0;do{menu();printf("请选择:");scanf("%d", &input);switch (input){case 1:game();break;case 0:printf("退出游戏\n");default :printf("输入错误,请重新输入:");}} while (input);
}int main()
{test();return 0;
}

期待我后续扫雷游戏的详细介绍吧

我是云边有个稻草人

期待与你的下一次相遇!Bye~

http://www.zhongyajixie.com/news/44232.html

相关文章:

  • 做网站可以用php如何把自己的网站推广出去
  • 个人网站做联盟营销手机网站模板
  • 网站建设中url相对路径最新新闻今天最新新闻
  • wordpress网页地址seo和sem的关系
  • 做网站的具体内容360官方网站网址
  • 做网站前段可以考什么证书seo网站管理
  • 百度关键字怎么搜到公司网站苏州整站优化
  • 政府门户网站建设策划网页推广怎么收取费用
  • 海外网站测速网站关键词公司
  • 做公众号封面的网站百度搜索引擎优化怎么做
  • 1688阿里巴巴国际站首页电脑培训学校网站
  • 服务器托管服务商seo短视频网页入口引流免费
  • 做装饰材料的网站百度seo排名优化公司推荐
  • 无锡怎么做网站推广怎样查询百度收录和排名情况
  • 网站的价值与网站建设的价格南宁seo排名收费
  • 商城网站建设报价单查询关键词排名软件
  • 网站建设宣传 mp4石狮seo
  • 佛山网站优化搜索引擎seo关键词优化方法
  • 网络推广的定义网站seo推广seo教程
  • dw做网站链接搜索引擎营销经典案例
  • 有代码怎么做网站旺道seo推广效果怎么样
  • 做彩网站百度电脑版下载官网
  • 网站制公司优化网站排名方法
  • 工程公司名字大全集百度seo公司兴田德润
  • 广东深圳网站建设网络营销常用的工具
  • 厦门中小企业建网站补助百度竞价推广运营
  • 怎么看一个网站有没有做百度推广东莞网站定制开发
  • 上海到北京多少公里太原网站制作优化seo公司
  • 网站开发需要哪些知识和工具公司seo是什么职位
  • 万户建站北京百度seo