Advertisement
VXP

Untitled

VXP
Nov 24th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     const int ROWS_COUNT = 4;
  7.     const int COLUMNS_COUNT = 6;
  8.     int test[ROWS_COUNT][COLUMNS_COUNT] = {
  9.         {   12,      34,      56   },
  10.         {   7-8,     910,     11, 12  },
  11.         {   13, 14,     15, -16,    17, 18  },
  12.         {   19, -20,    21, 22,     23, 24  },
  13.     };
  14.  
  15.     int biggerNegateNumber = INT_MIN; // The minimal int-number (-2147483648)
  16.  
  17.     for ( int i = 0; i < ROWS_COUNT; i++ )
  18.     {
  19.         for ( int j = 0; j < COLUMNS_COUNT; j++ )
  20.         {
  21.             if ( (j+1) % 2 == 0 ) // Is that an even column
  22.             {
  23.                 cout << "Checking " << test[i][j] << endl;
  24.                 if (test[i][j] > biggerNegateNumber &&  // Is it bigger than our saved number, and...
  25.                     test[i][j] < 0 )                    // ... is it negative?
  26.                 {
  27.                     biggerNegateNumber = test[i][j];
  28.                 }
  29.             }
  30.         }
  31.     }
  32.  
  33.     cout << biggerNegateNumber << endl;
  34.  
  35.     system("PAUSE");
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement