题解 | #计算小球走过的路程和反弹高度#
计算小球走过的路程和反弹高度
https://www.nowcoder.com/practice/ac674f68367149d5ad1f857a379e69c9
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
// 下落的高度和落地的次数
double h;
int n;
double h1 = h;
cin >> h;
cin >> n;
// write your code here......
for (int i=1; i<n; i++)
{
h /= 2;
h1 += 2 * h;
}
printf("%.1f", h1);
cout << " ";
printf("%.1f", h/2);
return 0;
return 0;
}
查看15道真题和解析