1 条题解

  • 1
    @ 2025-7-24 11:30:25
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int a,b,f=0;
    	cin>>a>>b;
    	char c[a+1][b+1];
    	for(int i=0;i<a;i++)
    		for(int j=0;j<b;j++)
    			cin>>c[i][j];
    	for(int i=0;i<a;i++)
    	{
    		for(int j=0;j<b;j++)
    		{
    			f=0;
    			if(c[i][j]=='*') 
    				cout<<"*";
    			else 
    			{ 
    				
    				if(c[i+1][j]=='*') f++;
    				if(c[i-1][j]=='*') f++;
    				if(c[i][j+1]=='*') f++;
    				if(c[i][j-1]=='*') f++;
    				if(c[i-1][j-1]=='*') f++;
    				if(c[i-1][j+1]=='*') f++;
    				if(c[i+1][j-1]=='*') f++;
    				if(c[i+1][j+1]=='*') f++;
    				cout<<f;
    			}
    		}
    		cout<<endl;
    	}
    	return 0;
    }
    
    • 1

    信息

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