题解 | #输入n个整数,输出其中最小的k个#

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

http://www.nowcoder.com/practice/69ef2267aafd4d52b250a272fd27052c

#基本上就是三行代码就可以搞定的事,严重怀疑这道题的难度是不是分错了。难道又是因为语言用的是python(手动狗头)?

while True:
    try:
        n,k=map(int,input().split())
        arr=sorted(list(map(int,input().split())))
        print(' '.join(map(str,arr[:k])))
    except:
        break
全部评论

相关推荐

评论
6
3
分享

创作者周榜

更多
牛客网
牛客企业服务