Programming
Assignment 22
You are a programmer for the Jet
Propulsion Laboratory. They want you to
analyze digitized representations of the night sky and print star maps.
The digitized representations of the
night sky have intensities which range from 0 to 20, where each number
represents the brightness of that portion of the image. A star is assumed to be present at location [r][c] if
(intensity[r][c] + sum of 4 surrounding
intensities)/5.0 >= 6
where intensity[r][c] is the intensity at location
[r][c].
Use the following input data. It's in a file called prog22.dat, which you can copy into your working directory with the
command cp
/home/dienerd/prog22.dat . (Note the period on the end of the command.)
0 3 4 0 0 0 6 8 12 5 3
5 13 6 10 0 0 12 3 4 2 16
2 6 2 7 3 0 10 0 1 0 4
0 0 4 15 4 1 6 0 2 7 3
0 0 7 2 6 9 1 4 18 5 9
5 0 6 10 6 2 8 0 17 4 1
3 1 4 9 2 12 7 1 3 9 6
Your output should look something like the following although
the stars will be in different locations.
NIGHT SKY
--------------------------
| |
| * * |
| * * |
| * * |
| * |
| |
| * * * * |
--------------------------
In writing your program you should use
the following outline.
1. Read the data into a two dimensional
array intensity using a
function
void
Input(int intensity[ROWS][COLS])
2. Fill a second two dimensional array
sky with '*' where there are stars and ' ' where there are no stars. Ignore possible stars along the edges of the
array. Do this in a function
void FindStar(int
intensity[ROWS][COLS], char sky[ROWS][COLS])
3. Print your sky map using a function
void
Output(char sky[ROWS][COLS])
.