Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. int jumpIt(const int board[], int startIndex, int endIndex)
  2. {
  3. int cost = board[startIndex];
  4. if(startIndex >= endIndex && endIndex%2 == 0)
  5. {
  6. return board[endIndex];
  7. }
  8. else if(startIndex >= endIndex && endIndex%2 != 0)
  9. {
  10. return cost;
  11. }
  12. else if(board[startIndex+1] < board[startIndex + 2])
  13. {
  14. cost = (board[startIndex] + jumpIt(board, startIndex + 1, endIndex));
  15. return cost;
  16. }
  17. else if(board[startIndex+2] < board[startIndex +1])
  18. {
  19. cost = (board[startIndex] + jumpIt(board, startIndex + 2, endIndex));
  20. return cost;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement