题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#

求小球落地5次后所经历的路程和第5次反弹的高度

https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446

#include <cmath>
#include <iostream>
using namespace std;

int main() {
    int start_height;
 
    cin >> start_height;
    float height = start_height;
    float dis = start_height;
    for(int i = 0; i < 5; i++){
        if(i < 4) dis += height;
        height /= 2;
    }
    cout << dis << endl << height << endl;
    return 0;
}

全部评论

相关推荐

Rena1ssance_:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务