DescriptionThe little volcano has recently been fond of Weiqi. In fact, the small volcano is ignorant of Weiqi. Now on the board, there are many small pieces of volcanoes. If there is such a position on the board, then this position will also become a small volcanic pawn, such a position refers to the small volcanic pieces to the position around. Now, the little volcano wants to know what the actual board looks like. Come on, help him!
InputThe input first line is an integer t (T <= 30), representing a total of T-group data. For each set of data, the first behavior is two integers n, m (1 <= N, M <= 25), followed by a n*m matrix representing the chessboard, where "." Represents the position where the pawn is not placed, "*" represents a piece of a small volcano.
OutputFor each set of data output a n*m chessboard, representing the actual chessboard.
Sample Input
23 3****.****4 4.*. *.*.*.*.. *..
Sample Output
Case 1:*********case 2:.*. ***.***.. *..
First record '. ' The coordinates, and then the first one '. ' The coordinates of a deep search, search '. ' Are marked if the search point is not on the outermost note that these points must be surrounded by ' * ', all become ' * '.
1#include <cstdio>2#include <string.h>3 intdx[4]={-1,1,0,0};4 intdy[4]={0,0,-1,1};5 Charmap[ -][ -];6 intflag[ -][ -];7 intN,m,good;8 structStu9 {Ten intx, y; One}key[ +]; A voidFintXxintyy) - { - intnx,ny,i,j; the if(xx==0|| xx = = N1|| yy = =0|| yy = = m1)//determine if the point is peripheral - { -Good=1; - } + for(i =0; I <4; i++) - { +nx=xx+Dx[i]; Any=yy+Dy[i]; at if(NX >=0&& NY >=0&& NX < n && NY < m && Flag[nx][ny] = =0&& Map[nx][ny] = ='.') - { -flag[nx][ny]=1; - f (nx,ny); - } - } in } - intMain () to { + intt,s=0; - thescanf"%d",&t); * $ while(t--)Panax Notoginseng { - inti,j,k; the + intnum=0; A thescanf"%d%d",&n,&m); + -memset (Map,'.',sizeof(map)); $ $ for(i =0; I < n; i++) - { -scanf"%s", Map[i]); the for(j =0; J < M; J + +) - {Wuyi if(Map[i][j] = ='.') the { -key[++num].x=i; Wukey[num].y=J; - } About $ } - } - for(i =1; I <= num; i++) - { Amemset (Flag,0,sizeof(flag));//we need to clear 0 every time . + theGood=0; - $flag[key[i].x][key[i].y]=1; the the if(Map[key[i].x][key[i].y] = ='.') the the f (key[i].x,key[i].y); - in if(Good = =0)//good=0 shows no outermost point. the { the for(k =0; K < n; k++) About { the for(j =0; J < M; J + +) the { the if(Flag[k][j] = =1) +map[k][j]='*'; - } the }Bayi } the } theprintf"Case %d:\n",++s); - - for(i =0; I < n; i++) the { the for(j =0; J < M; J + +) the { theprintf"%c", Map[i][j]); - } the theprintf"\ n"); the }94 } the}
Zzulioj 1908 Little volcano's Go dream