题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
#include <stdio.h> void fun(double h){ double s = h; double fin = 0; for(int i = 0; i < 4; i++){ h /= 2; s += h * 2; fin = h; } printf("%g\n%g", s, fin / 2); } int main(){ int h; scanf("%d", &h); fun((double)h); //printf("%.6f\n%.6f", fun((float)h)); return 0; }