返回列表 發帖
  1. import java.util.Arrays;
  2. import java.util.Comparator;


  3. public class CH21 {
  4.         Integer n[]={12,3,65,7,19,41,27,32};
  5.         CH21(){
  6.                 System.out.println("原始資料:");
  7.                 for(int i:n)
  8.                         System.out.print(i+" ");
  9.                 System.out.println("\n");
  10.                 Arrays.sort(n, new Comparator<Integer>() {
  11.                         public int compare(Integer o1, Integer o2) {
  12.                                 return o2-o1;
  13.                         }
  14.                 });
  15.                 System.out.println("遞減排序後:");
  16.                 for(int i:n)
  17.                         System.out.print(i+" ");
  18.                 System.out.println();
  19.         }
  20.         public static void main(String[] args) {
  21.                 new CH21();
  22.         }

  23. }
複製代碼
hahahahahahahaha

TOP

返回列表