
Problem:
A ball falls freely from a height of 100 meters, and after each landing, it rebounds to half of its original height; after falling again, how many meters has it traveled by the 10th landing? How high is the 10th rebound?
NEXT


Solution 1:
#include<stdio.h>#defineINITIAL_HEIGHT100.0#defineBOUNCE_COUNT10intmain(){ doubleh = INITIAL_HEIGHT; doubles = INITIAL_HEIGHT; // Height of the first rebound h /= 2; // Calculate subsequent rebound heights and total distance for(inti = 2; i <= BOUNCE_COUNT; i++){ s += 2 * h; h /= 2; } // Output result, specifying 2 decimal places printf(“By the %d-th landing, the total distance traveled is %.5f meters, and the height of the %d-th rebound is %.5f meters\n“, BOUNCE_COUNT, s, BOUNCE_COUNT, h); return0;}
END

July 20, 2025, SundayStrive for self-improvement
Layout | Liu Zhitang
Beauty | Liu Zhitang
Editor | Han Xinran, Zeng Xiangyu
Proofreader | Shi Ling, Qiao Shan
Reviewer | Lin Zhen, Yin Na
