ObjectiveThe objective of this problem is to ensure that students know how to use 2 dimensional array and simple looping technique.Problem DescriptionGiven a 2 dimensional array of size N x M containing 1 or 0 and a query (ROW or COLUMN), determine the sum of the numbers in the array corresponding to the query. For example, query ROW 3 means sum all the elements in the 3rd row of the array.InputThe first line of the input contains two integers, N (1 <= N <= 100) and M (1 <= M <= 100). The next line is an array with size N x M. The next line is the query with format ROW x, (1 <= x <= N) or COLUMN y, (1 <= y <= M).OutputOutput the answer to the query.Sample Input4 51 0 1 0 10 1 0 1 01 1 1 0 10 0 1 0 0ROW 3Sample Output4Explanation1 0 1 0 10 1 0 1 0ROW 3 1 1 1 0 10 0 1 0 0The sum of numbers in row 3 is 4
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.