这个扫雷没有标记功能,英文纯手搓,没有用翻译器,有什么语法错误还请各位大佬指出
#include<bits/stdc++.h>
using namespace std;
int g[12][12]={0},x,y,cj=100,cj1=0,v[12][12];
char fh='l',g1[11][12];
bool jg=true,xxs=true;
int pd(int x,int y,int sun){
if(g[x+1][y]==9) sun++;
if(g[x][y+1]==9) sun++;
if(g[x-1][y]==9) sun++;
if(g[x][y-1]==9) sun++;
if(g[x+1][y+1]==9) sun++;
if(g[x-1][y+1]==9) sun++;
if(g[x-1][y-1]==9) sun++;
if(g[x+1][y-1]==9) sun++;
return sun;
}
void dfs(int q,int p){
int xxl=0;
g1[q][p]=g[q][p]+48;
v[q][p]=1;
if(g[q+1][p]==0) xxl++;
if(g[q][p+1]==0) xxl++;
if(g[q-1][p]==0) xxl++;
if(g[q][p-1]==0) xxl++;
if(g[q+1][p+1]==0) xxl++;
if(g[q-1][p+1]==0) xxl++;
if(g[q-1][p-1]==0) xxl++;
if(g[q+1][p-1]==0) xxl++;
if(xxl>=4) {
if(g[q+1][p]<3&&v[q+1][p]!=1) dfs(q+1,p);
if(g[q][p+1]<3&&v[q][p+1]!=1) dfs(q,p+1);
if(g[q-1][p]<3&&v[q-1][p]!=1) dfs(q-1,p);
if(g[q][p-1]<3&&v[q][p-1]!=1) dfs(q,p-1);
if(g[q+1][p+1]<3&&v[q+1][p+1]!=1) dfs(q+1,p+1);
if(g[q-1][p+1]<3&&v[q-1][p+1]!=1) dfs(q-1,p+1);
if(g[q-1][p-1]<3&&v[q-1][p-1]!=1) dfs(q-1,p-1);
if(g[q+1][p-1]<3&&v[q+1][p-1]!=1) dfs(q+1,p-1);
}
}
int main(){
srand(time(NULL));
for(int i=0;i<11;++i)
for(int j=0;j<11;++j) g1[i][j]=35;
for(int i=0;i<12;++i)
for(int j=0;j<12;++j) g[i][j]=10;
for(int i=0;i<12;++i)
for(int j=0;j<12;++j) v[i][j]=0;
cout<<"GAME!\n";
cout<<"The name of the game in Chinese is SaoLei\n";
cout<<"For:Find all the boon at once\n";
cout<<"The ways to use the game are here:\n";
cout<<"Use the number to move your flag\n";
cout<<"Then,use the letter 'Y' to show it out,use the letter 'F' to mark it or cancel marking it\n";
cout<<"(Must not use other letter!)/n";
cout<<"Remember,use the letter 'R' to inprot the number again\n";
cout<<"It is not a boon if it is number '0' and it is the boon if it is number '9'\n";
cout<<"Have a good time playing!And thank you for your playing!\n\n";
_sleep(1500);
for(int i=1;i<=10;++i)
while(1) {
x=rand()%11;
y=rand()%11;
if(g[x][y]!=9&&x!=0&&y!=0&&x!=11&&y!=11) {
g[x][y]=9;
break;
}
}
for(int i=1;i<=10;++i)
for(int j=1;j<=10;++j)
if(g[i][j]!=9) g[i][j]=pd(i,j,0);
while(xxs) {
if(jg) {
cout<<" ";
for(int i=1;i<=10;++i) printf("%d ",i);
cout<<"\n";
for(int i=1;i<=10;++i) {
printf("%2d ",i);
for(int j=1;j<=10;++j){
cout<<g1[i][j]<<" ";
}
cout<<"\n";
}
cin>>x>>y;
cin>>fh;
while(fh!='Y'&&fh!='R'&&fh!='F') {
cout<<"Wrong!Please inprot again\n";
fh='l';
cin>>fh; }
while(x<=0||x>10||y<=0||y>10) {
cout<<"Wrong!Please inprot again\n";
cin>>x>>y; }
if(fh=='R') continue;
if(fh=='F'){
if(g1[x][y]=='*'){
g1[x][y]='#';
cout<<"Mark Success!\n";
}
else if(g1[x][y]=='#'){
g1[x][y]='*';
cout<<"Cancel Success!\n";
}
}
if(fh=='Y') {
if(g[x][y]==9) {
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nGame Over!\n";
jg=false;
return 0; }
else {
g1[x][y]=g[x][y]+48;
dfs(x,y);
}
}
cout<<"\n";
}
for(int i=1;i<=10;++i)
for(int j=1;j<=10;++j) if(g1[i][j]=='*'&&g[i][j]==9) cj1++;
cj=cj1;
if(cj==10) {
cout<<" ";
for(int i=1;i<=10;++i) printf("%d ",i);
cout<<"\n";
for(int i=1;i<=10;++i) {
printf("%2d ",i);
for(int j=1;j<=10;++j) cout<<g1[i][j]<<" ";
cout<<"\n"; }
cout<<"You are win!You are a winer!\n";
xxs=false;
}
cj1=0;
}
cout<<"Inprot a letter in all the letters to get off";
return 0;
}