MATRIX WITH HIGHEST SUM


Take string input then form all possible mXm square matrix, and print the matrix with maximum sum. In case, two or more square matrix has maximum sum then print largest matrix followed by next largest matrix and so on. In case, more than one matrix has same size print in order of their occurrence.  

INPUT: 

6, 3, 6, 20, 3, 6,-15, 3, 3

OUTPUT:           

6 3 6         
20 3 6        
-15 3 3 
                 
6 3          
6 20                     

6 20          
3 6

Explanation:-  

6 3 6 
20 3 6 -> its sum is 35 and is order 3*3,
-15 3 3

6 3
6 20 -> its sum is 35 and is order 2*2,

6 20
3 6 -> its sum is 35 and is order 2*2,

No comments:

Post a Comment

DISTRIBUTE BOOKS | Code vita 2019

Problem Description  For enhancing the book reading, school distributed story books to students as part of the Children’s day celebration...