当前位置:网站首页>C langage pour le déminage (version simplifiée)
C langage pour le déminage (version simplifiée)
2022-06-24 20:27:00 【AKA. Traitement de la pupille】
#define ROW 9
#define COL 9
#define ROWS 2 + ROW
#define COLS 2 + COL
#define shuliang 10
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
void quyu(char mine[ROWS][COLS], int rows, int cols, char n)
{
int i = 0;
int j = 0;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
{
mine[i][j] = n;
}
}
}
void xianshi(char show[ROWS][COLS], int row, int col)
{
int i = 0;
int j = 0;
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 ", show[i][j]);
}
printf("\n");
}
printf("\n");
}
void buzhi(char mine[ROWS][COLS], int row, int col)
{
int m = shuliang;
int x = 0;
int y = 0;
while (m)
{
x = rand() % row + 1;
y = rand() % row + 1;
if (mine[x][y] == '0')
{
mine[x][y] = '1';
m--;
}
}
}
int zhouweilei(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 play(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 - shuliang)
{
printf("Veuillez saisir les coordonnées:");
scanf("%d %d", &x, &y);
if (x >= 1 && x <= row && y >= 1 && y <= col)
{
if (mine[x][y] == '1')
{
printf("Mort.\n");
xianshi(mine, ROW, COL);
printf("Fin du jeu\n");
break;
}
else
{
int m = zhouweilei(mine, x, y);
show[x][y] = m + '0';
xianshi(show, ROW, COL);
}
}
else
{
printf("Veuillez saisir à nouveau\n");
continue;
}
win++;
}
if (win == row * col - shuliang)
{
printf("J'ai gagné.\n");
xianshi(mine, ROW, COL);
}
}
void meun()
{
Sleep(5000);
char a1[] = "******** 1. play *******";
char a2[] = "******** 0. exit *******";
char a3[] = "######## #######";
char a4[] = "######## #######";
int left1 = 0;
int right1 = strlen(a1) - 1;
int left2 = 0;
int right2 = strlen(a2) - 1;
while (left1 < right1 && left2 < right2)
{
a3[left1] = a1[left1];
a3[right1] = a1[right1];
a4[left2] = a2[left2];
a4[right2] = a2[right2];
printf("%s\n", a3);
printf("%s\n", a4);
left1++;
right1--;
left2++;
right2--;
Sleep(100);
system("cls");
}
printf("%s\n", a3);
printf("%s\n", a4);
}
void game()
{
char mine[ROWS][COLS] = { 0 };
char show[ROWS][COLS] = { 0 };
quyu(mine, ROWS, COLS, '0');
quyu(show, ROWS, COLS, '*');
buzhi(mine, ROW, COL);
xianshi(show, ROW, COL);
play(mine, show, ROW, COL);
}
void saolei()
{
int xuanze = 0;
srand((unsigned int)time(NULL));
do
{
meun();
printf("Veuillez entrer:");
scanf("%d", &xuanze);
switch (xuanze)
{
case 1:
printf("Commencez le jeu\n");
game();
break;
case 0:
printf("Quitter le jeu\n");
break;
default:
printf("Erreur d'entrée\n");
break;
}
} while (xuanze);
}
int main()
{
saolei();
return 0;
}边栏推荐
- 视频平台如何将旧数据库导入到新数据库?
- 网络安全审查办公室对知网启动网络安全审查,称其“掌握大量重要数据及敏感信息”
- The difference between the lazy man mode and the hungry man mode
- Showcase是什么?Showcase需要注意什么?
- Steering gear control (stm32f103c8t6)
- 得物多活架构设计之路由服务设计
- 云计算发展的 4 个阶段,终于有人讲明白了
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
- DX12引擎开发课程进度-这个课程到底讲到哪里了
- 16个优秀业务流程管理工具
猜你喜欢

Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1

苹果、微软、谷歌不再掐架,今年要合力干一件大事

What about the Golden Angel of thunder one? Golden Angel mission details

物聯網?快來看 Arduino 上雲啦

Test drive citus 11.0 beta (official blog)

Information theory of popular science Shannon
![[R tidyverse] use of select verb](/img/2d/768391bc6ec497432915024bc90842.jpg)
[R tidyverse] use of select verb

Methods for comparing float types in the kernel

实现基于Socket自定义的redis简单客户端

Bytebase加入阿里云PolarDB开源数据库社区
随机推荐
Eureka source code shallow reading - automatic fault removal
R for Data Science (notes) -- data transformation (used by filter)
Coinbase将推出首个针对个人投资者的加密衍生产品
The agile way? Is agile development really out of date?
RF_ DC system clock setting gen1/gen2
云计算发展的 4 个阶段,终于有人讲明白了
Bytebase joins Alibaba cloud polardb open source database community
《梦华录》“超点”,鹅被骂冤吗?
Install the custom module into the system and use find in the independent project_ Package found
Accurate calculation of task progress bar of lol mobile game
Application practice | massive data, second level analysis! Flink+doris build a real-time data warehouse scheme
等等党们的胜利!挖矿退潮后,显卡价格全面暴跌
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
Error in Android connection database query statement
Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
Bytebase 加入阿里云 PolarDB 开源数据库社区
16 excellent business process management tools
You can capture fingerprints with a mobile camera?! Accuracy comparable to signature and monogram, expert: you are aggravating discrimination
Apple doesn't need money, but it has no confidence in its content
Map跟object 的区别