标签:
import java.util.Arrays; import java.util.Scanner; public class GetKSmallNum { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int num = scan.nextInt(); int out = scan.nextInt(); int []arr = new int[num]; int top = 0; while (num>0) { arr[top++] = scan.nextInt(); num--; } Arrays.sort(arr); for (int i = 0; i < out; i++) { System.out.print(arr[i]); if(i!=out-1) System.out.print(" "); } } }注意最后没有空格
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/liaction/article/details/47839145