c语言扫雷项目制作压缩包
立即下载
资源介绍:
c语言扫雷项目制作压缩包
#include"game.h"
void menu()
{
printf("**********************\n");
printf("****** 1.start *****\n");
printf("****** 0.exit *****\n");
printf("**********************\n");
}
void build_dilei(char d[henghang][zonglie], int a, int b, char e)
{
int f, g;
for (f = 0; f < b; f++)
{
for (g = 0; g < a; g++)
{
d[g][f] = e;
}
}
}
void print(char d[henghang][zonglie], int a, int b)
{
int f, g, h;
printf("--------扫雷--------\n");
for (h = 0; h < b+1; h++)
{
printf("%d ", h);
}
printf("\n");
h = 1;
for (f = 1; f < a+1; f++)
{
printf("%d ", h);
h++;
for (g = 1; g < b+1; g++)
{
printf("%c ", d[g][f]);
}
printf("\n");
}
printf("--------扫雷--------\n");
}
void mailei(char d[henghang][zonglie], int a, int b)
{
int lei, x, y;
for (lei = 10; lei;)
{
x = rand() % 9 + 1;
y = rand() % 9 + 1;
if (d[x][y] != '1')
{
d[x][y] = '1';
lei--;
}
}
}
int serch(char d[henghang][zonglie], int a, int b, int e, int h)
{
int f, g;
int c = 0;
for (f = h-1; f <= h + 1; f++)
{
for (g = e-1; g <= e + 1; g++)
{
if (d[g][f] == '1')
{
c ++ ;
}
}
}
return c;
}
void combine(char d[henghang][zonglie], char c[henghang][zonglie], int a, int b, int e, int h)
{
int f, g, j, i;
for (f = h - 1; f <= h + 1; f++)
{
for (g = e - 1; g <= e + 1; g++)
{
int k = 0;
for (j = f - 1; j <= f + 1; j++)
{
for (i = g - 1; i <= g + 1; i++)
{
if (c[i][j] == '1')
{
k++;
}
}
}
if (k== 0)
{
d[g][f] = '0';
}
}
}
}
int count(char d[henghang][zonglie], int a, int b)
{
int f, g, h;
h = 0;
for (f = 1; f < a + 1; f++)
{
for (g = 1; g < b + 1; g++)
{
if (d[g][f] == '*')
h++;
}
}
if (h == 10)
return 1;
return 0;
}
void see(char d[henghang][zonglie], char c[henghang][zonglie], int a, int b)
{
int f, g, j,i,m,n;
for (f = 1; f < a + 1; f++)
{
for (g = 1; g < b + 1; g++)
{
if (d[g][f] == '0')
{
for (j = f - 1; j <= f + 1; j++)
{
for (i = g - 1; i <= g + 1; i++)
{
int l = 0;
for (m = j - 1; m <= j + 1; m++)
{
for (n = i - 1; n <= i + 1; n++)
{
if (c[n][m] == '1')
{
l++;
}
}
}
d[i][j] = (int)48 + l;
}
}
}
}
}
}