/*
题目:一球从100米高度*落下,每次落地后反跳回原高度的一半;再落下,求它在
第10次落地时,共经过多少米?第10次反弹多高?
*/
import java.util.*;
public class Class10 {
public static void main(String[] args) {
int h0 = 100;
int h = 0;
int ht = 0;
int dh = 0;
int h1 = 0;
System.out.println("请输入第几次落下:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n == 1){
h = h0;
ht = h0/2;
System.out.println("共经过的米数:");
System.out.println(h);
System.out.println("反弹的高度:");
System.out.println(ht);
}else if(n <= 0){
System.out.println("输入有误!");
}else{
for(int i = 2; i <= n; i++){
ht = h0/(2*(i - 1));
//System.out.println(ht);
dh = ht*2;
h1 = h1 + dh;
//System.out.println(h1);
}
h = h0 + h1;
System.out.println("共经过的米数:");
System.out.println(h);
System.out.println("反弹的高度:");
System.out.println(ht);
}
}
}