输入n个整数,输出其中最小的k个

输入n个整数,输出其中最小的k个_牛客网

https://www.nowcoder.com/practice/69ef2267aafd4d52b250a272fd27052c?tpId=37&tqId=21281&rp=0&ru=/ta/huawei&qru=/ta/huawei/question-ranking

while True:
    try:
        [n1,n2]=[int(i) for i in input().split()]
        s=[int(j) for j in input().split()]
        s.sort()
        print(' '.join(map(str,s[:n2])))
    except:
        break
#注意输入与输出的格式

全部评论
大神,请问,那个n1就没用了吗?怎样处理题中说的,输入数量和实际输入数量对等的问题呢?
点赞 回复 分享
发布于 2021-06-03 12:14

相关推荐

评论
7
收藏
分享

创作者周榜

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