import java.util.Arrays;
import java.util.Scanner;
public class Main{
static int N = 35;
static int a[][] = new int[N][N];
static boolean st[][] = new boolean[N][N];
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
for(int i = 1; i <= n ; i++) {
for(int j = 1; j <= m ;j ++) {
a[i][j] = scanner.nextInt();
}
}
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m ; j ++) {
if(j+1<=m&&j-1>0) {//横的不越界检查横的
if(a[i][j]==a[i][j-1]&&a[i][j]==a[i][j+1]) {
st[i][j] = true;st[i][j+1] = true;st[i][j-1] = true;
}
}
if(i-1>0&&i+1<=n) {//竖的不越界检查竖的
if(a[i][j]==a[i-1][j]&&a[i][j]==a[i+1][j]) {
st[i][j] = true;st[i+1][j] = true;st[i-1][j] = true;
}
}
}
}
for(int i = 1 ;i <= n; i ++) {
for(int j = 1; j <= m ; j ++) {
System.out.print((st[i][j]?0:a[i][j])+" ");
}
System.out.println();
}
}
}
网友评论