public class HeightDemo {
/**
* 题目:一球从100米高度*落下,每次落地后反跳回原高度的一半;
* 再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
*/
public static void main(String[] args) {
double h = 100;
double total = 0;
for (int i = 0; i < 10; i++) {
if (i == 0) {
total = total + h;
} else {
h = h / 2;
total = total + 2 * h;
}
}
System.out.println("total=" + total);
System.out.println("h=" + h);
}
}
相关文章
- ValueError: too many values to unpack (expected 4)
- Display LOV (List Of Values) Using Show_Lov In Oracle Forms
- ValueError: Length of values does not match length of index
- SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
- 再谈vertical-align与line-height
- Phoenix插入数据出现异常:Values in UPSERT must evaluate to a constant
- html中,元素width和height的单位px、cm、mm、in、pc、pt、ch、em、rem、vh、vw、vmin、vmax的含义
- 微信小程序 设置height 100%不起作用
- Chapter 2:A Tale of Two Values_《clean architecture》notes
- 利用max-height适应多尺寸屏幕的下拉动画