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