Advertisement
RoshHoul

apples

Oct 10th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int board[3][3] =
  6. { 2, 9, 9,
  7.   6, 1, 9,
  8.   0, 4, 9 };
  9.  
  10. bool moveDown (int row, int col) {
  11.     if (row+1 > 3 || col+1 > 3) {
  12.         return;
  13.     }
  14.     return board[row][col+1] < board[row+1][col];
  15.    
  16. }
  17.  
  18. int main() {
  19.     int columns = 2; int rows = 2;
  20.     int sum = board[0][0];
  21.    
  22.     for (int i = 0; i < 3; i++) {
  23.         for (int j = 0; j < 3; j++) {
  24.             cout << "current is: " <<board[i][j] << endl;
  25.            
  26.             if (moveDown(i, j)) {
  27.                 i++;
  28.             } else {
  29.                 j++;
  30.             }
  31.             sum += board[i][j];
  32.             cout << "next is: " <<board[i][j] << endl;
  33.         }
  34.         cout << "sum: " << sum << endl;
  35.     }
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement