改了好几次,又不知道错哪了,但是电脑一debug就死机,所以只能求助万能的谷民们了qwq
#include<bits/stdc++.h>
using namespace std;
const int N=10;
vector<vector<bool> >b;
vector<bool> c;
vector<string> s;
string str;
string s1="yizhong";
int n;
int dx[8]={-1,-1,0,1,1,1,0,-1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
bool flag=false;
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>str;
s.push_back(str);
for(int j=0;j<n;j++){
c.push_back(true);
}
b.push_back(c);
c.clear();
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=0;k<8;k++){
if(s[i][j]!='y') continue;
else if(i+dx[k]*6>=0 and i+dx[k]*6<n and j+dy[k]*6>=0 and j+dy[k]*6<n){
for(int x=1;x<=6;x++){
if(s[i+dx[k]*x][j+dy[k]*x]!=s1[x]){
flag=true;
break;
}
}
if(flag){
for(int x=0;x<=6;x++){
s[i+dx[k]*x][j+dy[k]*x]=false;
}
}
flag=false;
}
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(b[i][j]) cout<<'*';
else cout<<s[i][j];
}
cout<<endl;
}
return 0;
}
不尽感谢。