只有40分,怎么回事?
查看原帖
只有40分,怎么回事?
1469121
Hongryan楼主2025/7/31 21:29

错误的代码:

#include<bits/stdc++.h>
using namespace std;
char a[100][100];
int b[100][100];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(a[i][j]=='?')
			{
				if(a[i+1][j]=='*')b[i][j]++;
				if(a[i-1][j]=='*')b[i][j]++;
				if(a[i][j+1]=='*')b[i][j]++;
				if(a[i][j+1]=='*')b[i][j]++;
				if(a[i+1][j+1]=='*')b[i][j]++;
				if(a[i+1][j-1]=='*')b[i][j]++;
				if(a[i-1][j+1]=='*')b[i][j]++;
				if(a[i-1][j-1]=='*')b[i][j]++;
				cout<<b[i][j];
			}
			else cout<<"*";
		}
		cout<<endl;
	}
    return 0;
} 

只有22338899 四个测试点对。

2025/7/31 21:29
加载中...