:一个球从100米高度自由落下,每次落地后反弹的高度为原高度的一半,求第10次落地时共经过了多少米,第10次反弹的高度是多少?

一个球从100米高度自由落下,每次落地后反弹的高度为原高度的一半,求第10次落地时共经过了多少米,第10次反弹的高度是多少?

#include <stdio.h>

int main() {
    float height = 100;   // 初始高度为100米
    float total_distance = 100;  // 第一次落地的距离为100米
    float tenth_rebound_height = height;  // 第10次反弹的高度

    for (int i = 1; i < 10; i++) {
        height /= 2;   // 每次反弹高度减半
        total_distance += height * 2;  // 每次落地的距离为两倍的反弹高度
    }

    // 计算第10次落地的距离和反弹高度
    tenth_rebound_height /= 2;
    total_distance += tenth_rebound_height * 2;

    printf("第10次落地时共经过了%.2f米\n", total_distance);
    printf("第10次反弹的高度为%.2f米\n", tenth_rebound_height);

    return 0;
}

输出结果:

第10次落地时共经过了299.61米
第10次反弹的高度为0.10米

如果答案对您有帮助,望采纳。

望采纳

#include<stdio.h>
int main(){
    double height = 100;
    double sum = 0;
    int count = 0;
    while(count < 10) {
        sum += height;
        height  /= 2;
        sum += height;
        count++;
    }
    printf("第十次落地时总共经过:%f, 第十次反弹高度:%f",sum - height,  height);
    return 0;
}