Functions and Recursions – Geometry – Problem #4

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: hard

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

Back to Lab Problems
Functions and Recursions/Geometry/Problem #4

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #4

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.