首页 > 代码库 > c-100米球反弹

c-100米球反弹

 1 #include <iostream> 2  3 #define TIMES 10 4  5 int 6 main(void) { 7     float  sumHeight = 100; 8     float bouceHeight = sumHeight / 2;    //第一次反弹的高度. 9     for(int i = 2; i <= TIMES; i++) {10         sumHeight += 2 * bouceHeight;    //第i次经过的距离.11         bouceHeight /= 2;    //第i次即将反弹的高度.12     }13     printf("第%d次落地时经过:%g 米,反弹高度为:%g",TIMES, sumHeight, bouceHeight);14     //第10次落地时经过:299.609 米,反弹高度为:0.097656315 }

 

c-100米球反弹