using namespace std;
int main()
{
int N,n,m;
int arr[102][102] = {0};
cin >> N;
for (int i = 0;i < N; i++)
{
cin >> n >> m;
for (int a = 1;a <= n; a++)
{
for (int b = 1;b <= m; b++)
{
cin >> arr[a][b];
}
}
if (i > 0)
cout << endl;
for (int a = 1;a <= n; a++)
{
for (int b = 1;b <= m; b++)
{
if (arr[a][b] == 1)
{
if (arr[a - 1][b] == 0 || arr[a + 1][b] == 0 || arr[a][b - 1] == 0 || arr[a][b + 1] == 0)
cout << "0 ";
else
cout << "_ ";
}
else
cout << "_ ";
}
cout << endl;
}
}
return 0;
}
沒有留言:
張貼留言