Assessment 2009 2 Easy

From Progzoo
Jump to: navigation, search

Easy problems These problems use the data format similar to that shown in image1.txt The first two tokens give the width and height of the image, the following numbers represent 0 for a black pixel and 1 for a white pixel.

8 8
1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 1
1 0 1 1 1 1 0 1
1 0 1 1 1 1 0 1
1 0 1 1 1 1 0 1
1 0 1 1 1 1 0 1
1 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1

Count Black Pixels

Count the number of black pixels. The output for this image1.txt would be: 20


[Font] [Default] [Show] [Resize] [History] [Profile]

Count Black Pixels on Row 4

Output the number of black pixels on row number 4. The first row has number 0. In this example the output would be:

2


[Font] [Default] [Show] [Resize] [History] [Profile]


Rows with Black Pixels

Output the row number of every row that includes a black pixel:

1 2 3 4 5 6 


[Font] [Default] [Show] [Resize] [History] [Profile]

Count Rows with Black Pixels

Output the row number of every row that includes a black pixel:

6 


[Font] [Default] [Show] [Resize] [History] [Profile]

Count White Rows

Output the row number of every row that includes a black pixel:

2 


[Font] [Default] [Show] [Resize] [History] [Profile]