题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半,再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
1 2 3 4 5 6 7 8 9 10 11 12 13
| #include <stdio.h> int main() { float height = 100; int count = 0; float distance = 0; for (count=1; count<=10; count++) { distance = height + distance; height = height / 2; printf("第%d次落地,下次高度:%lf,总距离:%lf\n",count,height,distance); } return 0; }
|