题解 | #输入n个整数,输出其中最小的k个#
输入n个整数,输出其中最小的k个
https://www.nowcoder.com/practice/69ef2267aafd4d52b250a272fd27052c
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); int num = fzhinput.nextInt(); int k = fzhinput.nextInt(); int zs[] = new int[num]; fzhinput.nextLine(); for(int i=0;i<num;i++){ zs[i]=fzhinput.nextInt(); } Arrays.sort(zs); for(int i=0;i<k;i++){ System.out.print(zs[i]+" "); } } }