80分,有两个测试点错误
查看原帖
80分,有两个测试点错误
892571
ltzx2022_kanxinyi_5楼主2023/3/19 10:16
#include <iostream>
using namespace std;
int ar[101][101];
char ch[101][101];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>ch[i][j];
			if(ch[i][j]=='*')
			{
				ar[i+1][j-1]++;
				ar[i+1][j]++;
				ar[i+1][j+1]++;
				ar[i][j-1]++;
				ar[i][j]=ch[i][j];
				ar[i][j+1]++;
				ar[i-1][j-1]++;
				ar[i-1][j]++;
				ar[i-1][j+1]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(ch[i][j]=='*')
			{
				cout<<'*';
			}else{
				cout<<ar[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}
2023/3/19 10:16
加载中...