【程序
10
】
题目:一球从 100 米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第 10 次落地时,共经过多少米?第 10 次反弹多高?
题目:一球从 100 米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第 10 次落地时,共经过多少米?第 10 次反弹多高?
public
class Test10
{
public static void main (String[] args)
{
double h = 100;
double sub=0;
for( int i=1;i<=10;i++)
{
sub = sub+h;
h = h/2;
}
System.out.println( "第10次落地时,小球运行的距离为:" +sub);
System.out.println( "第10次弹起后的高度为:"+h);
}
}
{
public static void main (String[] args)
{
double h = 100;
double sub=0;
for( int i=1;i<=10;i++)
{
sub = sub+h;
h = h/2;
}
System.out.println( "第10次落地时,小球运行的距离为:" +sub);
System.out.println( "第10次弹起后的高度为:"+h);
}
}
转载于:https://blog.51cto.com/shylx123/554816