1,750 views
1 votes
1 votes

Consider a matrix M of integers. Divide M into 4 sub-matrices. These sub-matrices are called as Quadrants. Report the Quadrant number which has the smallest minimum-element. If two or more quadrants have same smallest minimum, report the smallest quadrant index.
The matrix M is divided into four quadrants by halving the rows and columns. If row/column is an odd number, divide them in such a way that the first half of the row/column should be one smaller than the second half.

The four quadrants are numbered from 1 to 4 in the structure shown below:

Q1 | Q2
---  + ---
 Q3 | Q4
INPUT FORMAT: M is a matrix of integers. You would be given two numbers m and n specifying the number of rows and columns. This would be followed by m lines of n integers each specifying the data of the m*n matrix M.
n and m will be greater than 1 and less than 12

 OUTPUT FORMAT: Print in a separate line, the quadrant number with the smallest minimum-element.

 


 

1 Answer

0 votes
0 votes
#include<stdio.h>
int main()
{
   int m, n, c, d, matrix[10][10], minimum;
  scanf("%d%d",&m,&n);
  
   for( c = 0 ; c < m ; c++ )
   {
      for( d = 0 ; d < n ; d++ )
      {
         scanf("%d",&matrix[c][d]);
      }
   }
   
   minimum = matrix[0][0];
 
   for( c = 0 ; c < m ; c++ )
   {
      for( d = 0 ; d < n ; d++ )
      {
         if ( matrix[c][d] > minimum )
            minimum = matrix[c][d];
      }
   }
 
   printf("%d",minimum);
 
   return 0;
}

//I tried this much only..

Related questions

0 votes
0 votes
1 answer
3
simi2426 asked Aug 9, 2022
830 views
In how many ways can the word ‘DOCUMENTATION’ be arranged so that all the consonants come together.