题解 | 复读机

复读机

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

import sys


lines = sys.stdin.read().splitlines()

result = []
for line in lines:
    stripped = line.strip()
    if not stripped:
        result.append(stripped) # 保留空行
        continue

    try:
        num = float(stripped)
        if num.is_integer():
            result.append(stripped)
            continue

        value = format(num, ".1f")
        result.append(value)
        continue
    except Exception as e:
        pass
    result.append(stripped)
print("\n".join(result))

#算法##python3##python#
全部评论

相关推荐

饿魔:没人说?我来牛美孩
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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