.++.+.++++ .+.......+ .+.+++++.+ .+.+...+.+ .+.+.+.+.+ .+.+++.+.+ .+.....+.+ .+++++++.+ ........++ ...++++++. |
The symbols represent:
. - Road, empty space (floodable area)
+ - Buildings (non-floodable area)
You should create a two-dimensional array of char to store the town. You may use the following array initializer if you wish (copy and paste):
char town[10][10] = { {'.', '+', '+', '.', '+', '.', '+', '+', '+', '+'}, {'.', '+', '.', '.', '.', '.', '.', '.', '.', '+'}, {'.', '+', '.', '+', '+', '+', '+', '+', '.', '+'}, {'.', '+', '.', '+', '.', '.', '.', '+', '.', '+'}, {'.', '+', '.', '+', '.', '+', '.', '+', '.', '+'}, {'.', '+', '.', '+', '+', '+', '.', '+', '.', '+'}, {'.', '+', '.', '.', '.', '.', '.', '+', '.', '+'}, {'.', '+', '+', '+', '+', '+', '+', '+', '.', '+'}, {'.', '.', '.', '.', '.', '.', '.', '.', '+', '+'}, {'.', '.', '.', '+', '+', '+', '+', '+', '+', '.'} };
Your algorithm must be a general solution and work for all possible configurations of a 10 x 10 town, not just the configuration given above.
See the following sample run (user's input is in bold):
.++.+.++++ .+.......+ .+.+++++.+ .+.+...+.+ .+.+.+.+.+ .+.+++.+.+ .+.....+.+ .+++++++.+ ........++ ...++++++. Enter co-ordinates to flood (e.g.: 1 1): 11 10 Invalid input. Please try again. .++.+.++++ .+.......+ .+.+++++.+ .+.+...+.+ .+.+.+.+.+ .+.+++.+.+ .+.....+.+ .+++++++.+ ........++ ...++++++. Enter co-ordinates to flood (e.g.: 1 1): 1 2 0 new squares flooded. .++.+.++++ .+.......+ .+.+++++.+ .+.+...+.+ .+.+.+.+.+ .+.+++.+.+ .+.....+.+ .+++++++.+ ........++ ...++++++. Enter co-ordinates to flood (e.g.: 1 1): 2 1 19 new squares flooded. W++.+.++++ W+.......+ W+.+++++.+ W+.+...+.+ W+.+.+.+.+ W+.+++.+.+ W+.....+.+ W+++++++.+ WWWWWWWW++ WWW++++++. Enter co-ordinates to flood (e.g.: 1 1): 4 1 0 new squares flooded. W++.+.++++ W+.......+ W+.+++++.+ W+.+...+.+ W+.+.+.+.+ W+.+++.+.+ W+.....+.+ W+++++++.+ WWWWWWWW++ WWW++++++. Enter co-ordinates to flood (e.g.: 1 1): 8 9 30 new squares flooded. W++W+W++++ W+WWWWWWW+ W+W+++++W+ W+W+WWW+W+ W+W+W+W+W+ W+W+++W+W+ W+WWWWW+W+ W+++++++W+ WWWWWWWW++ WWW++++++. Enter co-ordinates to flood (e.g.: 1 1): 10 10 1 new square flooded. W++W+W++++ W+WWWWWWW+ W+W+++++W+ W+W+WWW+W+ W+W+W+W+W+ W+W+++W+W+ W+WWWWW+W+ W+++++++W+ WWWWWWWW++ WWW++++++W Enter co-ordinates to flood (e.g.: 1 1): 0 1 |