全网最简陋的扫雷

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
void reset(){/*重置界面*/
	system("cls");
	system("color 0f"); 
	system("title wzh的游戏空间");
}
void rest(){/*暂停*/
    system("pause");
}
int random(int a,int b){/*随机数*/
	b-=a;
	srand(time(0)); 
	return (rand()%b)+a;/*返回a和b之间的随机数*/
}
void sl(){/*扫雷*/ 
	reset();
	int pl=0,lx,cx,cy,ly;
	int sz[100][100]={0},seemap[100][100]={0},dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1},sum=0;
	for(int i=1;i<=10;i++){
		reset();
		cout<<"加载中,进度条:"<<endl;
		for(int j=0;j<i;j++){
			cout<<"|"<<"O@K";
		}
		for(int j=i;j<10;j++){
			cout<<"|"<<"N O";
		}
		lx=random(1,10);
		Sleep(random(600,1000));
		ly=random(1,10);
		if(sz[lx][ly]==9){
			Sleep(random(600,1000));
		}else{
			sz[lx][ly]=9;
			for(int o=0;o<8;o++){
	        	if(sz[lx+dx[o]][ly+dy[o]]!=9){
	            	sz[lx+dx[o]][ly+dy[o]]+=1;
				}
        	}
		}
	}
	reset();
	cout<<"加载完成";
	while(1){
		reset();
		cout<<"  ";
		for(int i=1;i<=10;i++){
			printf("%3.d ",i);
		}
		cout<<endl;
		for(int i=0;i<=9;i++){ 
			for(int j=-1;j<=9;j++){
				if(j==-1){
					printf("%2.d ",i+1);
					continue;
				}
				if(seemap[i][j]==1){
					cout<<" "<<sz[i][j]<<"  ";
				}else if(seemap[i][j]==0){
					cout<<" __ ";
				}
			}
			cout<<endl<<endl;
		}
		Sleep(1000);
		if(sum>=90){
			reset();
			cout<<"游戏成功"<<endl;
			Sleep(2000);
			cout<<"游戏结束";
		    Sleep(2000);
		}
		cout<<"请输入需要排查的地方在第几列:";
		cin>>cx;
		cout<<endl<<"请输入需要排查的地方在第几行:";
		cin>>cy;
		cx-=1;
		cy-=1;
		int ch=sz[cx][cy];
		if(ch==9){
			reset();
			cout<<"游戏失败"<<endl;
			Sleep(2000);
			cout<<"游戏结束"; 
		    Sleep(2000);
		}
		queue<int> x,y;
		x.push(cx);
	    y.push(cy);
		seemap[cx][cy]=1;
		while(!(x.empty()&&y.empty())){
			int nx=x.front();
			int ny=y.front();
			x.pop();
	        y.pop();
			for(int i=0;i<8;i++){
				int tx=nx+dx[i];
				int ty=ny+dy[i];
				if(0<=tx&&tx<10&&0<=ty&&ty<10&&((sz[tx][ty]==ch)||(sz[tx][ty]!=8&&sz[tx][ty]==char(ch+1)))&&seemap[tx][ty]==0){
					x.push(tx);
	                y.push(ty);
					seemap[tx][ty]=1;
					sum+=1;
				}
			}
		}
	}
}
int main(){
	sl();
}

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
void reset(){/*重置界面*/
    system("cls");
    system("color 0f"); 
    system("title wzh的游戏空间");
}
void rest(){/*暂停*/
    system("pause");
}
int random(int a,int b){/*随机数*/
    b-=a;
    srand(time(0)); 
    return (rand()%b)+a;/*返回a和b之间的随机数*/
}
void sl(){/*扫雷*/ 
    reset();
    int pl=0,lx,cx,cy,ly;
    int sz[100][100]={0},seemap[100][100]={0},dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1},sum=0;
    for(int i=1;i<=10;i++){
        reset();
        cout<<"加载中,进度条:"<<endl;
        for(int j=0;j<i;j++){
            cout<<"|"<<"O@K";
        }
        for(int j=i;j<10;j++){
            cout<<"|"<<"N O";
        }
        lx=random(1,10);
        Sleep(random(600,1000));
        ly=random(1,10);
        if(sz[lx][ly]==9){
            Sleep(random(600,1000));
        }else{
            sz[lx][ly]=9;
            for(int o=0;o<8;o++){
                if(sz[lx+dx[o]][ly+dy[o]]!=9){
                    sz[lx+dx[o]][ly+dy[o]]+=1;
                }
            }
        }
    }
    reset();
    cout<<"加载完成";
    while(1){
        reset();
        cout<<"  ";
        for(int i=1;i<=10;i++){
            printf("%3.d ",i);
        }
        cout<<endl;
        for(int i=0;i<=9;i++){ 
            for(int j=-1;j<=9;j++){
                if(j==-1){
                    printf("%2.d ",i+1);
                    continue;
                }
                if(seemap[i][j]==1){
                    cout<<" "<<sz[i][j]<<"  ";
                }else if(seemap[i][j]==0){
                    cout<<" __ ";
                }
            }
            cout<<endl<<endl;
        }
        Sleep(1000);
        if(sum>=90){
            reset();
            cout<<"游戏成功"<<endl;
            Sleep(2000);
            cout<<"游戏结束";
            Sleep(2000);
        }
        cout<<"请输入需要排查的地方在第几列:";
        cin>>cx;
        cout<<endl<<"请输入需要排查的地方在第几行:";
        cin>>cy;
        cx-=1;
        cy-=1;
        int ch=sz[cx][cy];
        if(ch==9){
            reset();
            cout<<"游戏失败"<<endl;
            Sleep(2000);
            cout<<"游戏结束"; 
            Sleep(2000);
        }
        queue<int> x,y;
        x.push(cx);
        y.push(cy);
        seemap[cx][cy]=1;
        while(!(x.empty()&&y.empty())){
            int nx=x.front();
            int ny=y.front();
            x.pop();
            y.pop();
            for(int i=0;i<8;i++){
                int tx=nx+dx[i];
                int ty=ny+dy[i];
                if(0<=tx&&tx<10&&0<=ty&&ty<10&&((sz[tx][ty]==ch)||(sz[tx][ty]!=8&&sz[tx][ty]==char(ch+1)))&&seemap[tx][ty]==0){
                    x.push(tx);
                    y.push(ty);
                    seemap[tx][ty]=1;
                    sum+=1;
                }
            }
        }
    }
}
int main(){
    sl();
}

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值