讨论 / 题解!飞扬同学来看看。。
fnoichzhe 2017-11-04 07:39:50
点我顶贴 收藏 删除
#include<bits/stdc++.h>

using namespace std;

int main(){

char a[110][110];

int f,e,s1,s2,o=0;

cin>>s1>>s2;

for(f=1; f<=s1; f++){

for(e=1; e<=s2; e++){

cin>>a[f][e];

}

}

for(f=1; f<=s1; f++){

for(e=1; e<=s2; e++){

o=0;

if(a[f][e]=='*')

cout<<"*";

else{

if(a[f-1][e-1]=='*')

o=o+1;

//1;

if(a[f-1][e]=='*')

o=o+1;

//2;

if(a[f-1][e+1]=='*')

o=o+1;

//3;

if(a[f][e-1]=='*')

o=o+1;

//4;

if(a[f][e+1]=='*')

o=o+1;

//5;

if(a[f+1][e-1]=='*')

o=o+1;

//6;

if(a[f+1][e]=='*')

o=o+1;

//7;

if(a[f+1][e+1]=='*')

o=o+1;

//8;

cout<<o;

}

}

cout<<endl;

}

return 0;

}

查看更多回复
提交回复