#include<iostream>
#include<cstdio>
#include<cstring>
#define M 35
#define N 85
using namespace std;
char graph[M][N],bound,mark;
int pocket,hv,m,n;
int next[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
void DFS_Visit(int,int);
int main()
{
int t,i=0,j,n;
//freopen("in.txt","r",stdin);
scanf("%d\n",&t);
m = -1;
while(t--)
{
while(gets(graph[++m]))
if(graph[m][0]=='_')
break;
for(i=0;i<m;i++)
{
n = strlen(graph[i]);
for(j=0;j<n;j++)
if(graph[i][j]!=' ')
{
bound = graph[i][j];
break;
}
if(graph[i][j]!=' ')
break;
}
for(i=0;i<m;i++)
{
n = strlen(graph[i]);
for(j=0;j<n;j++)
if(graph[i][j]=='*')
{
DFS_Visit(i,j);
break;
}
if(graph[i][j]=='*')
break;
}
for(i=0;i<=m;i++)
printf("%s\n",graph[i]);
m = -1;
}
return 0;
}
void DFS_Visit(int x,int y)
{
int i,tx,ty;
graph[x][y]='#';
for(i=0;i<4;i++)
{
tx=x+next[i][0],ty=y+next[i][1];
if(graph[tx][ty]==' ')
DFS_Visit(tx,ty);
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.