package javabasi; /** * 题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高? * @author dlmu * */ public class BallBounce { public static void main(String[] args) { double height = 100; double length = 0; for (int i = 1; i <= 10; i++) { length = length + height; height = height / 2; } System.out.println("after 10 times, the final height is:" + height); System.out.println("total length it has passed is:" + length); } }
逻辑要明确,计算清楚,看清题
时间: 2024-10-25 05:49:49