-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path784.cpp
More file actions
53 lines (34 loc) · 832 Bytes
/
784.cpp
File metadata and controls
53 lines (34 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<stdio.h>
#include<stdlib.h>
/* Maze Exploration - 784 */
void paint(char maze[][81],int x,int y){
maze[x][y]='#';
if(maze[x][y-1] == ' ')
paint(maze,x,y-1);
if(maze[x][y+1] == ' ')
paint(maze,x,y+1);
if(maze[x-1][y] == ' ')
paint(maze,x-1,y);
if(maze[x+1][y] == ' ')
paint(maze,x+1,y);
}
main(){
int n,i,j,lin;
char maze[30][81];
n = atoi(gets(maze[0]));
for(;n>0;n--){
lin=0;
while(1){
gets(maze[lin]);
if(maze[lin][0] == '_')
break;
lin++;
}
for(i=0;i<lin;i++)
for(j=0;maze[i][j]!='\0';j++)
if(maze[i][j]=='*')
paint(maze,i,j);
for(i=0;i<=lin;i++)
puts(maze[i]);
}
}