返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;

  3. int main()
  4. {
  5.     int n,m;
  6.     cin>>n>>m;
  7.     int data[n][m];
  8.     for(int i=0;i<n;i++)
  9.     {
  10.         for(int j=0;j<m;j++)
  11.         {
  12.             cin>>data[i][j];
  13.         }
  14.     }
  15.     for(int i=0;i<n;i++)
  16.     {
  17.         for(int j=0;j<m;j++)
  18.         {
  19.             if(data[i][j]==0)
  20.             {
  21.                 cout<<' ';
  22.             }
  23.             else{
  24.                 if(i==0 || i==n-1 || j==0 || j==m-1 || data[i-1][j]==0 || data[i][j-1]==0 || data[i+1][j]==0 || data[i][j+1])
  25.                     cout<<'*';
  26.                 else
  27.                     cout<<' ';
  28.             }
  29.         }
  30.         cout<<endl;
  31.     }

  32.     return 0;
  33. }
複製代碼

TOP

返回列表