Advertisement
khaiwen1111

MW findlargest

Feb 4th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int NUMBER_OF_ROW = 4;
  4. const int NUMBER_OF_COLUMNS = 5;
  5.  
  6. void largestINRow(int arr[][NUMBER_OF_COLUMNS], int row)
  7. {
  8.     int i = 0;
  9.     int j ;
  10.     int max = 0;
  11.     int output[NUMBER_OF_ROW];
  12.     while (i < NUMBER_OF_ROW)
  13.     {
  14.         for (j = 0; j < NUMBER_OF_COLUMNS; j++)
  15.         {
  16.             if (arr[i][j] > max)
  17.                 max = arr[i][j];
  18.         }
  19.         output[i] = max;
  20.         cout << max<<endl;
  21.         max = 0;
  22.         i++;
  23.     }
  24.    
  25. }
  26. void main()
  27. {
  28.     int board[NUMBER_OF_ROW][NUMBER_OF_COLUMNS] = { {23,5,-6,15,-18},{4,16,24,67,-10},
  29.         {-12,54,23,76,11},{-1,12,34,22,8} };
  30.    
  31.     largestINRow(board, NUMBER_OF_ROW);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement