大佬求帮助莫名其妙的错误
查看原帖
大佬求帮助莫名其妙的错误
268346
only76楼主2020/6/15 15:17
#include<bits/stdc++.h>
using namespace std;
int a,b,c[105][105];
int main()
{
    cin>>a>>b;
    char shaolei[a][b];
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<b; j++)
        {
            cin>>shaolei[i][j];
            if(shaolei[i][j]=='*')
            {
                c[i][j]=1;
            }
        }
    }
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<b; j++)
        {
            if(c[i][j]==1)
            {
                cout<<"*";
            }
            else
            {
                cout<<c[i+1][j+1]+c[i+1][j-1]+c[i+1][j]+c[i][j+1]+c[i][j-1]+c[i-1][j+1]+c[i-1][j]+c[i-1][j-1];
            }
        }
        if(i!=a-1)
        {
            cout<<endl;
        }
    }




}

















































2020/6/15 15:17
加载中...