- #include <bits/stdc++.h>
- using namespace std;
- int a,b;
- int main()
- {
- cin>>a>>b;
- int x[a][b];
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<b;j++)
- {
- cin>>x[i][j];
- }
- }
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<b;j++)
- {
- if(x[i][j]==0)
- {
- cout<<" ";
- }else if(i==0 or i==a-1 or j==0 or j==b-1 or x[i+1][j]==0 or x[i-1][j]==0 or x[i][j+1]==0 or x[i][j-1]==0)
- {
- cout<<"*";
- }else
- {
- cout<<" ";
- }
- }
- cout<<endl;
- }
- return 0;
- }
複製代碼 |