Advertisement
maya97

1

Dec 11th, 2019
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1.  
  2.  
  3. /* A PROGRAM TO FIND THE MAXIMUM IN EACH COLOUMN OF A MATRICE AND FIND THE MINIMUM OF THOSE MAXIMUMS */
  4.  
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     cout << "A PROGRAM TO FIND THE MAXIMUM IN EACH COLOUMN OF A MATRICE AND FIND THE MINIMUM OF THOSE MAXIMUMS" << "\n";
  12.     int arr[3][3] = {{1,2,3} , {2,9,4} , {5,6,7}};
  13.     int arr1[3];
  14.     int max = arr[0][0];
  15.    
  16.     int i , j ;
  17.    
  18.     cout << "the array is : " << "\n" ;
  19.     for (i=0 ;  i < 3 ; i++ )
  20.     {
  21.         for (j=0 ; j < 3 ; j++)
  22.         {
  23.             if (arr[j][i] > max )
  24.             {
  25.                 max = arr[j][i];
  26.             }
  27.         }
  28.        
  29.         arr1[i] = max;
  30.         max = arr[0][i];
  31.        
  32.        
  33.     }
  34.     for (i=0 ; i<3 ; i++)
  35.     {
  36.         for (j=0 ; j<3 ; j++)
  37.         {
  38.             cout << arr[i][j] << " ";
  39.         }
  40.         cout << "\n" ;
  41.     }
  42.    
  43.     cout << "\n" ;
  44.    
  45.    
  46.     cout << "the maximum numbers of the coloumns are : "  ;
  47.     for (i=0 ; i<3 ; i++)
  48.     {
  49.         cout << arr1[i] << " ";
  50.     }
  51.    
  52.    
  53.     int min = arr1[0];
  54.    
  55.     for (i=0 ; i<3 ; i++)
  56.     {
  57.         if (arr1[i] < min )
  58.         {
  59.             min = arr1[i];
  60.         }
  61.     }
  62.     cout << "\n" ;
  63.     cout << "the minimum of all the elements is : " << min ;
  64.    
  65.    
  66.    
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement