题解
2022-11-27 09:58:15
发布于:江苏
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char a[105][105];
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)cin>>a[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(a[i][j]'')cout<<"";
else
{
int b=0;
for(int l=i-1;l<=i+1;l++)
for(int r=j-1;r<=j+1;r++)
if(a[l][r]'*')
b++;
cout<<b;
}
}
cout<<endl;
}
return 0;
}
全部评论 10
你编了个dr啊!:
编译错误: /code/judger/test/1892807411052548096/main.cpp:17:11: error: empty character constant
17 | if(a[i][j]'')cout<<"";
| ^~
/code/judger/test/1892807411052548096/main.cpp: In function 'int main()':
/code/judger/test/1892807411052548096/main.cpp:17:11: error: expected ')' before '\x0'
17 | if(a[i][j]'')cout<<"";
| ~ ^~
| )
/code/judger/test/1892807411052548096/main.cpp:23:11: error: expected ')' before ''
23 | if(a[l][r]'')
| ~ ^~~
| )2025-02-21 来自 云南
0What the hell does ac dog give birth to? Or an error?
2024-12-15 来自 浙江
0编译错误: /code/judger/test/1868138038275731456/main.cpp:17:11: error: empty character constant
17 | if(a[i][j]'')cout<<"";
| ^~
/code/judger/test/1868138038275731456/main.cpp: In function 'int main()':
/code/judger/test/1868138038275731456/main.cpp:17:11: error: expected ')' before '\x0'
17 | if(a[i][j]'')cout<<"";
| ~ ^~
| )
/code/judger/test/1868138038275731456/main.cpp:23:11: error: expected ')' before ''
23 | if(a[l][r]'')
| ~ ^~~
| )2024-12-15 来自 浙江
0I don't want to speak Chinese.
2024-12-15 来自 浙江
0The error is multiplied by 1000.
2024-12-15 来自 浙江
0#include <iostream>
#include <vector>using namespace std;
int main() {
int n, m;
cin >> n >> m;vector<vector<char>> grid(n, vector<char>(m)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> grid[i][j]; } } // 输出结果 for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (grid[i][j] == '*') { cout << '*'; } else { int count = 0; // 检查周围8个方向 for (int dx = -1; dx <= 1; ++dx) { for (int dy = -1; dy <= 1; ++dy) { if (dx == 0 && dy == 0) continue; // 跳过自身 int nx = i + dx, ny = j + dy; if (nx >= 0 && nx < n && ny >= 0 && ny < m && grid[nx][ny] == '*') { count++; } } } cout << count; } } cout << endl; } return 0;
}
Given by AI.2024-12-15 来自 浙江
0报错x4
2024-11-06 来自 广东
0编译错误: /code/judger/test/1836736091462660096/main.cpp:17:11: error: empty character constant
if(a[i][j]'')cout<<"";
^~
/code/judger/test/1836736091462660096/main.cpp: In function 'int main()':
/code/judger/test/1836736091462660096/main.cpp:17:11: error: expected ')' before '\x0'
/code/judger/test/1836736091462660096/main.cpp:23:11: error: expected ')' before ''
if(a[l][r]'')
^~~2024-09-19 来自 天津
0报错x3
2024-07-05 来自 北京
0报错
2024-06-05 来自 广东
0
有帮助,赞一个