therajat08

jumping on the clouds

Jul 7th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. int jumpingOnClouds(int c_count, int* c) {
  2.  
  3.     int i;
  4.     int currentPosition=0;
  5.     int safeJump=0;
  6.     int jumpCount=0;
  7.     while(currentPosition<c_count)
  8.     {
  9.        
  10.         for(i=currentPosition+1;i<c_count;c++)
  11.         {
  12.             if(c[i]==0)
  13.             {
  14.                 safeJump++;
  15.             }
  16.             else if (c[i]==1) {
  17.                 currentPosition+=safeJump;
  18.                 jumpCount+=safeJump;
  19.                 break;
  20.             }
  21.             else if (safeJump==2) {
  22.                 currentPosition+=safeJump;
  23.                 jumpCount+=safeJump;
  24.                 break;
  25.             }
  26.         }
  27.  
  28.     }
  29.    
  30.     return jumpCount;
  31. }
Add Comment
Please, Sign In to add comment