当前位置:网站首页>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;
}边栏推荐
- Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
- Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
- [go language questions] go from 0 to entry 4: advanced usage of slice, elementary review and introduction to map
- Anti epidemic through science and technology: white paper on network insight and practice of operators | cloud sharing library No.20 recommendation
- unity之模糊背景(带你欣赏女人的朦胧美)
- unity实战之lol技能释放范围
- Bytebase joins Alibaba cloud polardb open source database community
- Bytebase joins Alibaba cloud polardb open source database community
- Ribbon source code analysis @loadbalanced and loadbalancerclient
- 两位湖南老乡,联手干出一个百亿IPO
猜你喜欢

The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"

Where are Xiaomi mobile phone's favorite SMS and how to delete them

Uninstall tool v3.5.10.5670 single file portable official version

Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
![[R tidyverse] use of select verb](/img/2d/768391bc6ec497432915024bc90842.jpg)
[R tidyverse] use of select verb

天天鉴宝暴雷背后:拖欠数千万、APP停摆,创始人预谋跑路?

UART communication (STM32F103 library function)

Q1: error in JMeter filename must not be null or empty

宅男救不了元宇宙

Kubernetes cluster deployment
随机推荐
SQL export CSV data, unlimited number of entries
Eureka source code shallow reading - automatic fault removal
Fuzzy background of unity (take you to appreciate the hazy beauty of women)
Zadig + cave Iast: let safety dissolve in continuous delivery
[cann document express issue 06] first knowledge of tbe DSL operator development
Accurate calculation of task progress bar of lol mobile game
redis数据结构之压缩列表
Oracle create tablespaces and tables
Why is the executor thread pool framework introduced
[video tutorial] functions that need to be turned off in win10 system. How to turn off the privacy option in win10 computer
消息称腾讯正式宣布成立“XR”部门,押注元宇宙;谷歌前 CEO:美国即将输掉芯片竞争,要让台积电、三星建更多工厂...
Saltstack state state file configuration instance
Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month
Docker installing Oracle
思源笔记工具栏中的按钮名称变成了 undefined,有人遇到过吗?
Ribbon source code analysis @loadbalanced and loadbalancerclient
Stackoverflow annual report 2022: what are developers' favorite databases?
The largest DPU manufacturer in history (Part 1)
The agile way? Is agile development really out of date?