求一扫雷TC语言程序

来源:百度知道 编辑:UC知道 时间:2024/05/11 13:17:01
各位大哥帮帮忙,如果是网上下载的务扰

#include <stdio.h>
#include "stdlib.h"
# include "time.h"
# define s 20
int x; /*棋盘行数*/
int y; /*棋盘列数*/
int b; /*选择游戏难度 1简单2普通3困难4 自定义*/
int h; /*雷的个数*/

struct Games g;
struct Games
{
int game_int[s][s];
char game_char[s][s];
};

void InitialValue_game(struct Games *g)
/*棋盘初始化*/
{
int i,j;
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
(*g).game_int[i][j]=0;
(*g).game_char[i][j]='#';
}
}
}

void InitialMine_game(struct Games *g)
/*随机布雷*/
{
int i,j,next1,next2;
int sum=0;
srand((unsigned)time(NULL));
while(1)
{
i=rand()%x;
j=rand()%y;

if((*g).game_int[i][j]==9) continue;
(*g).game_int[i][j]=9;
++sum;
for(next1=-1;next1<2;next1++)
{
for(next2=-1;next2<2;n