1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include<iostream> using namespace std;
int main(){ char boom; bool sign[105][105]={0}; int xlimit,ylimit; cin>>ylimit>>xlimit; for(int i=1;i<=ylimit;i++){ for(int n=1;n<=xlimit;n++){ cin>>boom; if(boom=='*'){ sign[n][i]=1; } } } for(int i=1;i<=ylimit;i++){ for(int o=1;o<=xlimit;o++){ if(sign[o][i]==1){ cout<<"*"; }else cout<<sign[o-1][i-1]+sign[o-1][i]+sign[o-1][i+1]+sign[o][i-1]+sign[o][i+1]+sign[o+1][i-1]+sign[o+1][i]+sign[o+1][i+1]; } cout<<endl; } return 0; }
|