|
楼主
楼主 |
发表于 2018-7-2 16:00:07
|
只看该作者
- #include <iostream>
- using namespace std;
- const int mm=110;
- char a[mm][mm];
- int dr[]= {-1,-1,-1,+0,+0,+1,+1,+1};
- int dc[]= {-1,+0,+1,-1,+1,-1,+0,+1};
- int r,c,tr,tc,s,n,m,d;
- int main()
- {
- cin>>n>>m;
- ///首行首列被空着了 相当于外圈被空着了
- for (r=1; r<=n; r++)
- for (c=1; c<=m; c++) cin>>a[r][c];
- for (r=1; r<=n; r++)
- {
- for (c=1; c<=m; c++)
- if (a[r][c]=='*') cout<<'*';
- else
- {
- for (s=d=0; d<=7; d++)
- {
- tr=r+dr[d],tc=c+dc[d];
- s=s+(a[tr][tc]=='*');
- }
- cout<<s;
- }
- cout<<endl;
- }
- return 0;
- }
复制代码 |
|