[Huawei OD test questions] The minimum k number (C&Java&python) 100% pass rate

topic description

Input n integers, find the smallest k integers and output them in ascending order

enter

The first line enters two integers n and k
The second line enters an array of integers

output

Output the smallest k integers from small to large, separated by spaces

sample

enter

5 2
1 3 5 7 2

output

1 2

java code:

import java.util.*<

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/130915596