package Test_1;
import java.util.Scanner;
public class Test_10 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
float length = 100;
System.out.print("请输入次数:");
Scanner input = new Scanner(System.in);
int num = input.nextInt();
float s = 0;
for(int i=1;i<=num;i++){
s = s + length;
length = length / 2;
}
System.out.println("落地"+num+"次后,小球经过的距离为:"+s);
}
}
小球落地n次后,经过的距离
最新推荐文章于 2022-08-02 15:45:18 发布