day14

作者: 今生何求惟你 | 来源:发表于2018-06-24 23:27 被阅读5次

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

代码:

#include <stdio.h>

main()

{

int i;

float s=100.0,a=s/2;

for( i = 2;i <= 10;i++)

{

s=s+2*a;

a=a/2;

}

printf("The 10th high is %f,and the total long is %f.\n",a,s);

}

输出样例

day14

相关文章

网友评论

    本文标题:day14

    本文链接:https://www.haomeiwen.com/subject/izfjyftx.html