Assignment #4 - 92A

Assignment #4 - 92A


Asignment 4                                                Weight 30
-=-=-=-=-=-=                                               Due 18 Feb
                                >>> NOTE Update >>>    E-Mail to HQAB

Write a Fortran program that reads the values of the file as characters
and stores them in a 20x60 array of integers. When you read a '1' store
the value 255 and when you read a '0' the value 0. Then print that
array with '.' for the values 0 and 'X' for 255. The next step is to
create a second array of integers (18X58) and calculate its value by the
following rule:

Scan the array line by line starting at the second line and finishing at
the 19th line and from left to write starting from the second column and
ending at the 59 column.                                                y
For each value you read from the original array
(say p(i,j) ) calculate the value for the second array at the location
(i-1,j-1) (say newp(i-1,j-1) ) as follows:

      term= -p(i-1,j-1)-p(i,j-1)-p(i+1,j-1)
            -p(i-1,j)+8*p(i,j)-p(i+1,j)
            -p(i-1,j+1)-p(i,j+1)-p(i+1,j+1)
The i takes values from 2 to 19 and j from 2 to 59.
Then if term<128 store at newp(i-1,j-1) the value 0 else if term>=128
store at newp(i-1,j-1) the value 255.

Using the previous code to print the second array with '.' and 'X'.
Output the two arrays with neat titles and an brief explanation
of what they represent.

Here is the input data you should use:-
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000011111110000000000000000000000000000000000011100000000
000000011111110000000000000000000011111110000001111111000000
000000011111110000000000000000000011111110000011111111100000
000000011111110000000000000000000011111110000011111111100000
000000011111110000000000000000000000000000000011111111100000
000000011111110111111111111000000111111110000011111111100000
000000011111111111111111111100000011111110000001111111000000
000000011111111111111111111100000011111110000001111111000000
000000011111111111111111111100000011111110000000111110000000
000000011111110000000111111100000011111110000000011100000000
000000011111110000000111111100000011111110000000001000000000
000000011111110000000111111100000011111110000000111110000000
000000011111110000000111111100000011111110000001111111000000
000000011111110000000111111100000011111111100000111110000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000