Java实现对输入的n个数排序

输入n个数,对其进行排序

import java.util.Scanner;
import java.util.Arrays;
public class Main{
     public static void main(String[] args){
         Scanner in =  new Scanner(System.in);
         while (in.hasNext()){
             int n = in.nextInt();
             int [] arr =  new int [n];
             for ( int i= 0 ;i
                 arr[i] = in.nextInt();
             }
             Arrays.sort(arr);
             for ( int i= 0 ;i
                 System.out.print(arr[i]+ " " );
             System.out.println();
         }
     }
}

你可能感兴趣的:(简单算法)