1 package everyDay; 2 3 /* 4 * 题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高? 5 */ 6 public class FreeFall { 7 8 public static void main(String[] args) { 9 double sum = 0; 10 double down = 100; 11 double up; 12 13 for (int time = 1; time <= 10; time++) { 14 up = down / 2; 15 sum += up + down; 16 down = up; 17 } 18 19 System.out.println("time 10 : " + down); 20 System.out.println("all long: " + sum); 21 } 22 23 }
时间: 2024-10-28 05:28:03