Boolean Array


Submit solution

Points: 10 (partial)
Time limit: 8.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C

Write a menu driven C program that will get an N X N boolean matrix A (contains only 0's and 1's) and perform the following operations,

  1. check for ones

  2. sum

check for ones count the number of 1's in the array and print Yes if it is a majority element(more than half are 1's), otherwise print No.

sum - given two coordinates/index locations (x1, y1) and (x2, y2) and find the sum of all the elements of the grid which lies within the bounds of the given coordinates, i.e. the sum of the elements within the coordinates (x1, y1), (x2, y1), (x1, y2) and (x2, y2) including all the 4 mentioned index locations.

Sample Input1

3

1 0 0 0 1 0 0 0 0

1

Sample Output1

No

Sample Input2

3

1 1 0 0 1 0 0 0 0

2

0 0

1 1

Sample Output2

3

Explanation

3 is the size of square matrix. The next line contains the array elements. The next line contains the option number. For option 2, you have to provide the index locations after the option number.


Comments

There are no comments at the moment.