来自于:http://www.jb51.net/article/38051.htm

 

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

 

程序代码:

#include<stdio.h>
int main()
{
    int i;
    float sn=100,hn=sn/2;
    for(i=2;i<=10;i++)
    {
        sn=sn+hn*2; /*第n次落地时共经过的米数*/ 
        hn=hn/2; /*第n次反跳高度*/ 
    }
    printf("the total of road is %f\n",sn);
    printf("the tenth is %f meter\n",hn);
}