请问如何写这个踩地雷的C++?(请用我提供的骨干)

来源:百度知道 编辑:UC知道 时间:2024/06/24 00:39:48
骨干下载点
http://www.sendspace.com/file/01wmjk

我想要的输入和输出
Sample 1:

Enter number of mines (enter negative number to generate random mines):1
Enter the position of mine 0: 3 3

0 1 2 3 4 5 6
0 * * * * * * *
1 * * * * * * *
2 * * * * * * *
3 * * * * * * *
4 * * * * * * *
5 * * * * * * *
6 * * * * * * *

****
Action:
Detonate: d x y
Mark: m x y
Please enter command (command, x, y): d 2 3

0 1 2 3 4 5 6
0 * * * * * * *
1 * * * * * * *
2 * * * * * * *
3 * * 1 * * * *
4 * * * * * * *
5 * * * * * * *
6 * * * * * * *

****
Action:
Detonate: d x y
Mark: m x y
Please enter command (command, x, y): d 0 0
0 1 2 3 4 5 6
0
1
2 1 1 1
3 1 B 1
4 1 1 1
5
6
You win!!

//链接打不开
#include<iostream.h>
#include<stdlib.h>
#include<iomanip.h>

#define N 7// 可以在这里设置雷阵大小(必须是方阵)!

bool p1[N][N];
char p2[N][N];
int total_num;// 雷数
int open_num;

void Init();// 初始化
void LayMines();// 布雷
void Print();// 输出
bool GetCommand(int &x,int &y);// 获取命令和坐标并检测是否合理
bool SweepMines(int i,int j);// 依坐标排雷
void MarkMines();// 标记出雷点

void main()
{
int x,y;
Init();
LayMines();
Print();
while(true)
{
if(GetCommand(y,x))
{
if(SweepMines(x,y))
{
if((open_num+total_num)==N*N)
{
MarkMines();
Print();
cout<<"You win!! "<<endl;
return;
}
}
else
{
Print();
cout<<"You stept on a mine!\n"
<<"Game Over"<<endl;
return;
}

}
else