3 条题解

  • 0
    @ 2025-4-11 19:12:58
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	
    	int a,b,d,e;
    	char g;
    	cin>>a>>b;
    	int c[a+2][b+2];
    	for(d=0;d<a+2;d++)
    	{
    		for(e=0;e<b+2;e++)
    		{
    			c[d][e]=0;
    		}
    	}
    	for(d=1;d<a+1;d++)
    	{
    		for(e=1;e<b+1;e++)
    		{
    			cin>>g;
    			if(g=='*')
    			{
    				c[d][e]=1;
    			}
    		}
    	}
    	for(d=1;d<a+1;d++)
    	{
    		for(e=1;e<b+1;e++)
    		{
    			if(c[d][e]==1)
    			{
    				cout<<'*';
    			}
    			else
    			{
    				cout<<c[d-1][e-1]+c[d-1][e]+c[d-1][e+1]+c[d][e-1]+c[d][e]+c[d][e+1]+c[d+1][e-1]+c[d+1][e]+c[d+1][e+1];
    			}
    		}
    		cout<<endl;
    	}
    return 0;
    }
    
    

    信息

    ID
    292
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    43
    已通过
    13
    上传者