题解 | #实现四舍五入#

实现四舍五入

http://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0

using namespace std;

int main() {

    double d;
    cin >> d;

    // write your code here......
    cout << (d > 0 ? ((d - static_cast<int>(d)) > (static_cast<int>(d) + 1 - d) ? static_cast<int>(d) + 1  :static_cast<int>(d)) 
             : ((d - static_cast<int>(d)) < (static_cast<int>(d) - 1 - d) ? static_cast<int>(d) - 1  :static_cast<int>(d)));

    return 0;
}
全部评论

相关推荐

就在我现在公司的隔壁每天经过都唏嘘不已(就是羡慕)什么时候可以到这里上班啊
柯基在debug:从大学毕业投简历到现在了,应届的时候我都面到终面了,现在工作四年了连简历初筛都过不了了
投递莉莉丝游戏等公司8个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-29 17:30
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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