G11|A126407.GESP
2026-07-20 18:10:00
发布于:海南
53阅读
0回复
0点赞
模拟:
代码如下:
#include<bits/stdc++.h>
using namespace std;
int a[510][510];
int main()
{
int n,m,q,x,y;
cin >> n >> m >> q;
for(int i = 1;i<=q;i++)
{
cin >> x >> y;
a[x][y] = 9;
}
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++)
{
if(a[i][j]!=9)
{
if(a[i][j-1]==9)a[i][j]++;
if(a[i][j+1]==9)a[i][j]++;
if(a[i+1][j-1]==9)a[i][j]++;
if(a[i+1][j+1]==9)a[i][j]++;
if(a[i-1][j-1]==9)a[i][j]++;
if(a[i-1][j+1]==9)a[i][j]++;
if(a[i+1][j]==9)a[i][j]++;
if(a[i-1][j]==9)a[i][j]++;
}
if(a[i][j]!=9)
cout << a[i][j] << ' ';
else
cout << "* ";
}
cout << "\n";
}
return 0;
}
全部评论 1
?
2026-07-30 来自 浙江
0








有帮助,赞一个