🔥 Burn Fat Fast. Discover How! 💪

#include using namespace std; /* function to calculate jum | OFF CAMPUS UPDATES

#include

using namespace std;

/* function to calculate jumps required to cross

walls */

int jumpcount(int x, int y, int n, int height[])
{

int jumps = 0;


for (int i = 0; i < n; i++) {

if (height[i] <= x) {

jumps++;

continue;

}


/* If height of wall is greater than

up move */

int h = height[i];

while (h > x)

{

jumps++;

h = h - (x - y);

}

jumps++;

}

return jumps;
}

/*driver function*/

int main()
{

int x = 10, y = 1;

int height[] = { 11, 10, 10, 9 };

int n = sizeof(height)/sizeof(height[0]);

cout << jumpcount(x, y, n, height);

return 0;
}


Telegram
@freejobs77
@freejobs77
@freejobs77