Assume that the matrix M existsUse nested for loops to find

Assume that the matrix M exists.Use nested for loops to find the index pair of the largest element in the matrix and store it in the row vector r. r should contain the row index followed by the column index

Solution

HI, Please find my C++ code snippt to find maximum element.

You have not mentioned about Programing language, but I have given you geberal code. You can use this concept to write in any programing language of your choice.


   Given : matrix[rows][columns]

   int max = matrix[0][0] ; // initiaizing with first element

   int row=0, col = 0; // to store row and column number of maximum number

   for(int i=0; i<rows; i++){

       for(int j=0; i<columns; j++){

           if(matrix[i][j] > max){
               max = matrix[i][j];
               row = i;
               col = j;
           }
       }
   }

   // row and col store the max value\'s index

Assume that the matrix M exists.Use nested for loops to find the index pair of the largest element in the matrix and store it in the row vector r. r should cont

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site