Flood Fill v2.0
EE 312
Due: Thursday 3/14/19 at 10:00 PM

50 points

No loops in the flood fill algorithm. You can use a loop to read in the original "picture" file and to prompt the user for the input. Obviously the Flood Fill will have to be implemented in a function that can be called recursively.

----------------------------------------

Flood Fill

Given an input file of the following format (a fake picture):

yyywwbbbbbbbggggg
yyybbbbbbbgggbbbb
ybybybybybwwwwwyy
ybbbbggwwwwwwbbbg
ggggggwwbbbbbbbbb
yyyyyyyyybbbyyyyy
ggggyyyygggggyyyy

that uses characters to represent colors in a picture, you will need to write a function that will "flood fill" an area with another "color." For example. If I were to flood fill the pixel at row 0 col 6 (a"b") with a "P", I would get this:

yyywwPPPPPPPggggg
yyyPPPPPPPgggbbbb
yPyPyPyPyPwwwwwyy
yPPPPggwwwwwwbbbg
ggggggwwbbbbbbbbb
yyyyyyyyybbbyyyyy
ggggyyyygggggyyyy

Every pixel that has the same color and is connected to the area of the flood fill is changed to the new color.

Write a program that reads in a file (provided at the linux prompt) that is at most 25 rows and 25 columns and repeatedly prompts the user for a row and column number, and a "color". The program will fill that area with the new color, show the new picture and prompt the user again. The program will end when the user enters -1 for the row or column. You will use solve the problem with a recursive function.

Example Run:

linux prompt> ./flood_fill fake_picture.txt

yyywwbbbbbbbggggg
yyybbbbbbbgggbbbb
ybybybybybwwwwwyy
ybbbbggwwwwwwbbbg
ggggggwwbbbbbbbbb
yyyyyyyyybbbyyyyy
ggggyyyygggggyyyy

Enter a row: 0
Enter a column: 6
Enter a color: P

yyywwPPPPPPPggggg
yyyPPPPPPPgggbbbb
yPyPyPyPyPwwwwwyy
yPPPPggwwwwwwbbbg
ggggggwwbbbbbbbbb
yyyyyyyyybbbyyyyy
ggggyyyygggggyyyy

Enter a row: 1
Enter a column: 1
Enter a color: G

GGGwwPPPPPPPggggg
GGGPPPPPPPgggbbbb
GPGPyPyPyPwwwwwyy
GPPPPggwwwwwwbbbg
ggggggwwbbbbbbbbb
yyyyyyyyybbbyyyyy
ggggyyyygggggyyyy

Enter a row: -1
Enter a column: 1
Enter a color: G

----------------------------------------

NOTES: 

Turn in: One zipped file that includes: readme.txt (gives instructions for compiling and running code) and your source file(s). The makefile should create a executable program named "flood_fill". To make this process work better, zip the files on kamek before you transfer them back to your computer for turnin.

Upload: Turn in a zipped file named prog04ff_xxxxx.zip where xxxxxx is your UT EID to Canvas.

Be sure to follow the style standards for the course. 

rlp 2/25/19