一个球从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(){
int i,size;
double high,sum=0.0;
scanf("%lf %d",&high,&size);
for(i=1;i<=size;i++){ //用for()循环来模拟反弹的过程,
//注意不要忘了最后的反弹反弹高度以及开始落下的距离
//其他的中间过程都是两倍的反弹高度。
if(i==1){
sum+=high; //第一次落地时
}
else{
sum+=high*2; //中间过程都是两倍的反弹高度。
}
high=high/2; //反弹高度
}
printf("%.2lf %.2lf",high,sum);
return 0;
}
望采纳
#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;
}