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

axurerp如何做网站专门做排名的软件

axurerp如何做网站,专门做排名的软件,项目立项流程,济宁哪里有网站建设文章目录 一、游戏规则二、 代码逻辑三、游戏实现1. 游戏菜单设计2.设计雷区并随机布置雷(1) 设置雷区(2) 布置雷 3.排查雷 四、源码 一、游戏规则 1. 在9*9的小格子中,任意选取一个坐标(格子),选择后发现,如果没点中雷…

文章目录

  • 一、游戏规则
  • 二、 代码逻辑
  • 三、游戏实现
    • 1. 游戏菜单设计
    • 2.设计雷区并随机布置雷
      • (1) 设置雷区
      • (2) 布置雷
    • 3.排查雷
  • 四、源码

一、游戏规则

1. 在9*9的小格子中,任意选取一个坐标(格子),选择后发现,如果没点中雷的坐标,会显示数字(表示周围有几个雷),如果点中雷,游戏结束

排查雷

  • 如果这个位置不是雷,就计算这个位置的周围8个坐标有几个雷,并显示雷的个数
  • 如果是 雷 ,就炸死了,游戏结束
  • 如果把雷都找出来了,胜利,游戏结束
  • 链 接:网页版扫雷

扫雷01

2.选择后如图

扫雷02

3.点中雷的情况

扫雷03

二、 代码逻辑

  1. 游戏菜单设计
  2. 设计雷区并随机布置雷
  3. 排查雷

三、游戏实现

1. 游戏菜单设计

//test.c
#include "game.h"
void game() 
{printf("扫雷\n");
}
void menu() 
{printf("************************\n");printf("******    扫雷   *******\n");printf("******  1. play  *******\n");printf("******  0. exit  *******\n");printf("************************\n");
}
int main() 
{int input = 0;do {menu();printf("请选择>:");scanf("%d",&input);switch (input){case 1:game();break;case 0:printf("退出游戏\n");break;default:printf("选择错误,请重新选择\n");break;}} while (input);return 0;
}

menu

2.设计雷区并随机布置雷

(1) 设置雷区

设置一个9*9的二维数组,0表示没有雷,1表示雷

04

但是为了避免显示给玩家看的数字 1(雷的个数)与设置雷的 1 重合,所以选用 * 进行埋雷

因为扫雷 是扫周围的8个区域,会遇到扫越界问题

05
故变成11*11的二维数组
在这里插入图片描述
设置棋盘

//test.c 中的 game()
void game() 
{char mine[ROWS][COLS] = {0};//放置雷的数组char show[ROWS][COLS] = {0};//显示的数组InitBoard(mine,ROWS,COLS,'0');DisplayBoard(mine, ROW, COL);InitBoard(show,ROWS,COLS,'*');DisplayBoard(show, ROW, COL);}
//game.c
#include "game.h"
void InitBoard(char board[ROWS][COLS], int rows, int cols,char set) 
{int i = 0;int j = 0;for (i = 0; i < rows;i++){for (j = 0; j < cols;j++){board[i][j] = set;}}
}void DisplayBoard(char board[ROWS][COLS], int row, int col) 
{int i = 0;int j = 0;printf("--------扫雷---------\n");for (i = 0; i <= col;i++) {printf("%d ",i);//打印列标}printf("\n");for (i = 1; i <= row; i++) {printf("%d ",i);//打印行标for (j = 1; j <= col;j++){printf("%c ",board[i][j]);}printf("\n");}printf("--------扫雷---------\n");}
//game.h
#include <stdio.h>#define ROW 9
#define COL 9#define ROWS ROW+2
#define COLS COL+2void InitBoard(char board[ROWS][COLS],int rows,int cols,char set);
void DisplayBoard(char board[ROWS][COLS], int row, int col);

在这里插入图片描述

(2) 布置雷

在这里随机生成雷
字符0表示不是雷。字符1表示是雷

//game.c
void SetMine(char mine[ROWS][COLS], int row, int col) 
{int count = Easy_count;while (count) {int x = rand() % row + 1;//生成坐标1-9int y = rand() % col + 1;if (mine[x][y] =='0')	//避免在同一个地方布置雷{mine[x][y] = '1';count--;}		}
}

06

3.排查雷

输入排查雷的坐标,如果是雷则GAME OVER !,则如果不是雷,则显示该坐标周围有多少个雷

//game.c
//排查雷
int GetCountMine(char mine[ROWS][COLS],int x,int y) 
{return (mine[x - 1][y - 1] + mine[x - 1][y] + mine[x - 1][y + 1] +mine[x][y - 1]+ mine[x][y + 1] +mine[x + 1][y - 1] +mine[x + 1][y] + mine[x + 1][y + 1]) - (8 * '0');
}
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("GAME OVER!!!,被炸死了\n");DisplayBoard(mine,ROW,COL);break;}else {//不是雷,统计周围有多少雷int c = GetCountMine(mine,x,y);show[x][y] = c + '0';DisplayBoard(show,ROW,COL);win++;}}else {printf("坐标输入错误,重新输入\n");}}if (win == ((row * col)- Easy_count)) //需要排的区域数{printf("恭喜您,排雷成功!\n");}
}

排雷的周围坐标

x-1, y - 1x-1,yx-1,y+1
x, y - 1x,yx,y+1
x+1,y-1x+1,yx+1,y+1

排完的情况(这里设置80个雷(用于测试排雷成功),所以只有一个安全)
07

排到雷,游戏结束
在这里插入图片描述

四、源码

game.h

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define ROW 9
#define COL 9#define ROWS ROW+2
#define COLS COL+2#define Easy_count 10//初始化
void InitBoard(char board[ROWS][COLS],int rows,int cols,char set);
//显示
void DisplayBoard(char board[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);

test.c

#include "game.h"
void game() 
{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 menu() 
{printf("************************\n");printf("******    扫雷   *******\n");printf("******  1. play  *******\n");printf("******  0. exit  *******\n");printf("************************\n");
}
int main() 
{int input = 0;srand((unsigned int )time(NULL));//设置随机数种子do {menu();printf("请选择>:");scanf("%d",&input);switch (input){case 1:game();break;case 0:printf("退出游戏\n");break;default:printf("选择错误,请重新选择\n");break;		}} while (input);return 0;
}

game.c


#include "game.h"
//初始化棋盘
void InitBoard(char board[ROWS][COLS], int rows, int cols,char set) 
{int i = 0;int j = 0;for (i = 0; i < rows;i++){for (j = 0; j < cols;j++){board[i][j] = set;}}
}
//打印棋盘
void DisplayBoard(char board[ROWS][COLS], int row, int col) 
{int i = 0;int j = 0;printf("--------扫雷---------\n");for (i = 0; i <= col;i++) {printf("%d ",i);}printf("\n");for (i = 1; i <= row; i++) {printf("%d ",i);for (j = 1; j <= col;j++){printf("%c ",board[i][j]);}printf("\n");}printf("--------扫雷---------\n");}
//布置雷
void SetMine(char mine[ROWS][COLS], int row, int col) 
{int count = Easy_count;while (count) {int x = rand() % row + 1;//生成坐标1-9int y = rand() % col + 1;if (mine[x][y] =='0')	//避免在同一个地方布置雷{mine[x][y] = '1';count--;}}
}
//排查雷
int GetCountMine(char mine[ROWS][COLS],int x,int y) 
{return (mine[x - 1][y - 1] + mine[x - 1][y] + mine[x - 1][y + 1] +mine[x][y - 1]+ mine[x][y + 1] +mine[x + 1][y - 1] +mine[x + 1][y] + mine[x + 1][y + 1]) - (8 * '0');
}
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("GAME OVER!!!,被炸死了\n");DisplayBoard(mine,ROW,COL);break;}else {//不是雷,统计周围有多少雷int c = GetCountMine(mine,x,y);show[x][y] = c + '0';DisplayBoard(show,ROW,COL);win++;}}else {printf("坐标输入错误,重新输入\n");}}if (win == ((row * col)- Easy_count)) //需要排的区域数{printf("恭喜您,排雷成功!\n");}
}
http://www.hkea.cn/news/305942/

相关文章:

  • 小型企业网站系统cilimao磁力猫最新版地址
  • 铁岭网站建设移动网站广东网站seo
  • 网站模板插件sem和seo
  • 用wordpress制作网站模板沈阳seo
  • 优化一个网站多少钱宜昌网站seo
  • 刚做的网站怎么才能搜索到枸橼酸西地那非片功效效及作用
  • 罗湖区网站公司专业模板建站
  • 哪有备案好的网站国产系统2345
  • 网站开发怎么让别人看到最新营销模式有哪些
  • ssm网站开发源码百度推广多少钱一个月
  • 手游门户网站建设appstore关键词优化
  • 齐河网站开发seo服务内容
  • 北京微信网站建设费用想卖产品怎么推广宣传
  • 网站上线的步骤厦门网站推广公司哪家好
  • 网站做app的软件有哪些百度一下你就知道下载
  • 界面设计的重要性百度seo关键词排名推荐
  • 股票做T网站直播营销
  • 北京手机网站建设公司排名技术优化seo
  • wordpress可爱的主题seo优化教程
  • 自己可以申请网站做外卖吗网站描述和关键词怎么写
  • 公司网站网页设计seo站长工具推广平台
  • 重庆南岸营销型网站建设公司哪家专业真实的网站制作
  • 郑州企业网站建设兼职推广渠道
  • 网站哪些数据优化大师的作用
  • 政府网站集约化建设总结营销软文推广平台
  • 学网站开发跟那个专业最相近百度站长平台注册
  • 网站开发python电脑培训班有哪些科目
  • 惠州响应式网站哪家好云盘搜索
  • spring做网站合肥seo排名收费
  • 做58网站怎么赚钱二十个优化