自由落体:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?

#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);
}
发布了139 篇原创文章 · 获赞 4 · 访问量 93万+

猜你喜欢

转载自blog.csdn.net/qq_38490457/article/details/104784803