#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();
}