记录
Here
Code
/*----------------------------------------
+ 洛谷OJ P2670 扫雷游戏 +
+ https://www.luogu.com.cn/problem/P2670 +
----------------------------------------*/
#include<iostream>
using namespace std;
int main(){
char boom;
bool sign[105][105]={0};
int xlimit,ylimit;
cin>>xlimit>>ylimit; //输入x值y值限度
for(int i=1;i<=ylimit;i++){
for(int n=1;n<=xlimit;n++){
cin>>boom; //输入地雷图
if(boom=='*'){
sign[n][i]=1;//地雷标记
}
}
}
for(int i=1;i<=ylimit;i++){
for(int o=1;o<=xlimit;o++){
if(sign[o][i]==1){
cout<<"*";
}else cout<<sign[o-1][i-1]+sign[o-1][i]+sign[o-1][i+1]+sign[o][i-1]+sign[o][i+1]+sign[o+1][i-1]+sign[o+1][i]+sign[o+1][i+1];
}
cout<<endl;
}
return 0;
}
问题
liu@liudeMacBook-Pro 日常练习 % cd "/Volumes/Data/学习资料/高中/NOIP/日常 练习/" && g++ 洛谷P2670.cpp -o 洛谷P2670 && "/Volumes/Data/学习资料/高中/N常练习/"洛谷P2670
20 10
??????????
??????????
??????????
??????????
??????????
*?????????
???*??????
?*?**?????
??*????*??
*?????????
??????????
?????*????
??????????
??????????
*?????????
**????????
??????????
??*???????
*???????*?
??????????
00000000000000000000
00000000011100000000
0011100001*222210000
012*1011123*2**10000
01*2101*11*222321000
011100111111001*1000
11000000012210111000
*100000001**21000000
220000011223*1000000
*1000001*10111000000
liu@liudeMacBook-Pro 日常练习 %