原创c++小游戏《扫雷但是地狱难度》1.0.1版本

这个扫雷非常难,2500个格子,500个雷

#include<bits/stdc++.h>
using namespace std;
char m[51][51],rm[51][51];
int bombs=500; 
//int bxy[501][501];
int d[8][2]={{0,1},{0,-1},{1,1},{-1,1},{1,0},{-1,0},{-1,-1},{1,-1}};
void tancha(int x,int y){
	int t=0;
	if(rm[x+1][y+1]=='*') t++;
	if(rm[x+1][y-1]=='*') t++;
	if(rm[x-1][y+1]=='*') t++;
	if(rm[x-1][y-1]=='*') t++;
	if(rm[x][y+1]=='*') t++;
	if(rm[x][y-1]=='*') t++;
	if(rm[x+1][y]=='*') t++;
	if(rm[x-1][y]=='*') t++;
	if(t>0){
		m[x][y]=char(t+'0');
		rm[x][y]=char(t+'0');
	}
	else{
		for(int i=0;i<8;i++){
			tancha(x+d[i][0],y+d[i][1]);
		}
	}
	return;
}
void start() {
	for(int i=1; i<=50; i++) {
		for(int j=1; j<=50; j++) {
			m[i][j]='=';
			rm[i][j]='='; 
		}
	}
	for(int i=1;i<=500;i++){
		srand(time(0));
		int bx=rand()%50+1;
		int by=rand()%50+1;
		while(rm[bx][by]=='*'){
			bx=rand()%50+1;
			by=rand()%50+1;
		}
		rm[bx][by]='*';
	}
	while(1) {
		system("cls");
		for(int i=1; i<=50; i++) {
			for(int j=1; j<=50; j++) {
				cout<<m[i][j]<<' ';
			}
			cout<<endl;
		}
		cout<<"还剩"<<bombs<<"个雷\n";
		int x,y;
		cout<<"请输入你要操作的格子的坐标:";
		cin>>x>>y;
		cout<<"你要做什么?\n";
		cout<<"1.探查 2.排雷\n";
		int p;
		cin>>p;
		if(p==1){
			if(rm[x][y]=='*'){
				cout<<"你踩中了雷!";
				system("pause");
				return;
			}
			else tancha(x,y);
		}
		else if(p==2){
			if(rm[x][y]=='*')
				bombs--;
			m[x][y]='!';
			rm[x][y]='!';
		}
		if(bombs==0){
			cout<<"你胜利了!\n";
			system("pause");
		}
	}

}
int main() {
	system("color 07");
	cout<<"扫雷(地狱难度)\n";
	system("pause");
	start();
}

大家给个赞吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值