题解 | 乒乓球

乒乓球

https://www.nowcoder.com/practice/78660925b1cd49b6b2e43cb375ed7945

def simulate(s,k):#统计结果并输出的函数
    w, l = 0, 0
    for c in s:
        if c=='W':#注意大小写
            w += 1
        else:
            l += 1
        
        if (w>=k or l>=k) and abs(w-l)>=2:
            print(f'{w}:{l}')
            w, l = 0, 0

    print(f'{w}:{l}')

s = input()
simulate(s,11)#调用11分制
print()
simulate(s,21)#调用21分制

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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