Functions and Recursions – Geometry – Problem #4
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
2. Write a C program to read two integer values m and n (2<m<20 and 2< n<20). Fill an m by n matrix (m rows and n columns) with random integers in the range [0, 10] by calling the rand function. Display the matrix nicely formatted. Then call two functions findMax and findMin. findMax: This function should take the matrix and m and n as arguments. It should find a 3x3 submatrix for which sum of all elements is maximum. It should display this submatrix nicely formatted. If no unique submatrix having maximum sum is present, you can display any one of the submatrix having maximum Sum. findMin: This function should take the matrix and m and n as arguments. It should find a 3X3 submatrix whose sum of all elements is minimum. It should display this submatrix nicely formatted. If no unique submatrix having minimum sum is present, you can display any one of the submatrix having minimum sum. Example: Consider m=4 and n=4, and the following example random array: 6 0 5 3 2 7 3 9 1 5 7 8 3 4 6 7 Max submatrix: 7 3 9 5 7 8 4 6 7 Min submatrix: 6 0 5 2 7 3 1 5 7