Advertisement
apl-mhd

Frog jump

Aug 4th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3.  
  4. int solution(int X, int Y, int D);
  5.  
  6. int main(){
  7.  
  8. printf("%d ", solution(10, 85, 30));
  9.  
  10.     return 0;
  11. }
  12.  
  13.  
  14.  
  15.  
  16. int solution(int X, int Y, int D){
  17.  
  18.     int  count = 0;
  19.  
  20.     while(1){
  21.  
  22.  
  23.         if(X >= Y){
  24.  
  25.  
  26.             break;
  27.  
  28.         }
  29.  
  30.         X += D;
  31.  
  32.         count++;
  33.  
  34.     }
  35.  
  36. return count;
  37.  
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement