题解 | 复读机 使用substr输出

复读机

https://www.nowcoder.com/practice/9d381551b6ab40c4b5c3c8d60fe4066e

#include <iostream>
using namespace std;

int main() {
    string s;
    while (cin >>s) { // 注意 while 处理多个 case
        int p = s.find('.');
        if(p == -1){
            cout<<s<<endl;
        }else{
            if(s[p + 2] >= '5') s[p + 1] += 1;
            cout<<s.substr(0, p + 2)<<endl;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

caicaidog:现实里没实习的还是占多数的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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