Assume that a ball falls freely from any height. After each landing, it jumps back to half of the original height. Then, how many meters does it experience when it lands for 5th times? How high is the rebound of 5th times?
Input start height, int type
How many meters and how high the rebound is when the output reaches the ground for 5th times?
[Remove invalid 0 at the end of the decimal number]
Sample input: 1
Sample output: 2.875
0.03125
# Include <iostream> using namespace STD; double high (double H, int N); double total (double H, int N); int main () {int height; double total; cin> height; double fif; Total = total (height, 5); fif = high (height, 5); cout <total <Endl; cout <fif; return 0;} double high (double H, int N) {If (n = 1) return H/2; elsereturn high (H/2, N-1 );} double total (double H, int N) {If (n = 1) return h; else return 2 * high (H, N-1) + total (H, N-1 );}