2DArrayMenu
Submit solution
C
Points:
10 (partial)
Time limit:
8.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
Write a menu driven C program that will get an N X N matrix and perform the following operations,
- check for zero
- celebrity node
check for zero counts the number of zeros in the array and output Yes if more than half of the elements of the array is zero, otherwise prints No.
celebrity node - Given the grid position/index location(i,j), check if the node is a celebrity node. The node is a celebrity node if the 4 neighbors ((i-1,j),(i+1,j)(i,j1),(i,j+1)) are non-zero. Print 1 if it is a celebrity node, otherwise print 0.
Sample Input1
3
1 0 2 0 0 3 0 0 0
1
Sample Output1
Yes
Sample Input2
3
1 0 2 0 0 3 0 0 0
2
1 1
Sample Output2
0
Comments