Freefall: a ball free fall from a height of 100 meters, the anti-jump back after each landing half its original height; down again, find it at the 10th floor, after a total of how many meters? 10th rebound tall?

#include <stdio.h>

void main() {
    float s = 100.0, h = s / 2;
    int n;
    for (n = 2; n <= 10; n++) {
        s = s + 2 * h;/*第n次落地时共经过的米数*/
        h = h / 2; /*第n次反跳高度*/
    }
    printf("the total of road is %f meter\n", s);
    printf("the tenth is %f meter\n", h);
}
Published 139 original articles · won praise 4 · Views 930,000 +

Guess you like

Origin blog.csdn.net/qq_38490457/article/details/104784803