Python语言,给定n个数,并按从小到大的顺序,以列表的形式输出这n个数中前m小的数。

输入格式:第一行输入两个数n和m,第二行输入n个数
输出格式:输出一个数组(列表)

img


n,m =list(map(int,input().split(" ")))
a=list(map(int,input().split(" ")))
a.sort()
print(a[:m])

如有帮助,希望点一下下采纳