题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
HJ38()
func HJ38() {
guard let n = readLine() else { return }
var height: Float = Float(n)!
var length: Float = 0
for _ in 1...5 {
length += height*2
height /= 2
}
print(length-Float(n)!)
print(height)
}
#ios#
func HJ38() {
guard let n = readLine() else { return }
var height: Float = Float(n)!
var length: Float = 0
for _ in 1...5 {
length += height*2
height /= 2
}
print(length-Float(n)!)
print(height)
}
#ios#