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