Problem D
CONTOUR PAINTING
Inpu Fil Name D.DAT
Progra Sourc File D.PA o D. o D.CPP
contou o point i represente o tw dimensiona (2D
gri a illustrate i figur 1 Th point o th contou ar
specifie b th sam characte whic ca b an printabl
character differen tha .*. . (decima cod 176) ._ an space
I figur thi characte i .. (decima cod 219) Al th othe
point o th gri ar represente b spaces Th contou i
connected i.e an tw point o th contou ca b reache fro
on anothe b travelin vertically horizontall an diagonally
Moreover i i considere tha contou ca clos singl no
empt zon o gri points
012345678901234567890123456789
------------------------------
0|
1| ....................
2| ........ ....
3| .. ..
4| .. .. ..............
5| ................ ....
6| .. .. ..............
7 .. ..
8| ........ ....
9| ....................
0|
Figur 1 contour o 2 grid
Th characte . (decima cod 176 represent th colou
use t pain th contou a illustrate i figur 3 Th pain
i adde o on sid o th contou i suc wa tha eac
contou poin o th painte sid ha a leas on ..neighbou
horizontall o verticall a show i figur 2:
........
...... ........ ..........
...... ........ ....
fla zone concav corner conve corner
Figur Case o poin painting
contou ca b painte eithe fro insid o fro outside Th paintin sid i specifie b th presenc o th characte .*
insid o outsid th contou a show i figur 3 Notic tha
th sta i remove fro th gri onc th paintin i done.
.................... .................... interior
........ .... .......................... painting
.. * .. ........ .. ......
.. .. .............. .................. ................
................ .... .................. ..................
.. .. .............. .................. ................
.. .. ........ .. ......
........ .... ..........................
.................... ....................
befor paintin afte painting
* .................... exterior
.................... .......................... painting
........ .... .......... ......
.. .. .... ..............
.. .. .............. .... .. ..................
................ .... .................. ......
.. .. .............. .... .. ..................
.. .. .... ..............
........ .... .......... ......
.................... ..........................
....................
befor paintin afte painting
Figure 3 Painting a closed contour
You proble i t writ progra which read fro tex
fil numbe .n an .n grids eac gri containin singl
contou an singl star paint eac gri accordin t th
positio o th sta an output th painte grid t tex
file Eac contou i place o it gri i suc wa tha i i
full surrounde b fre gri point (spaces).
Th firs lin o th inpu tex fil contain th numbe o
grid t b painted Th nex line o th fil contai th
grids Th line whic represen gri ar terminate b
separatio lin ful o underscore (._.) Ther ar a mos 3
line an a mos 8 character i lin fo eac grid Th
line ca b o differen length
Th standar outpu fil contain th grid wit th painte
contour an wit th star removed Eac gri i outpu i th
sam forma i ha bee rea fro th inpu file includin th
separatio line Figur i a exampl o th inpu an th
outpu o th progra fo singl simpl contour.
.pa
a inpu -- numbe o grids
..............
.. * ..
..............
__________ _ separatio line
en o file
b output ..............
..............
..............
__________ _ separatio line
en o file
Figur 4 n exampl o progra inpu an output
..........................................................