import java.util.Arrays; import java.util.Scanner; public class BubbleSort { private static Scanner s; public static void main(String[] args) { // TODO Auto-generated method stub int[] scores = new int[10]; s = new Scanner(System.in); for (int i=0;i<scores.length;i++){ scores[i] = s.nextInt(); } for(int i=0;i<scores.length;i++){ for(int j=i+1;j<scores.length;j++){ if (scores[i]<scores[j]){ swap(scores,i,j); } } } System.out.print("冒泡排序輸出的結果是:"+Arrays.toString(scores)); } public static void swap(int[] arrays,int i,int j) { // TODO Auto-generated method stub int tmp = arrays[i]; arrays[i] = arrays[j]; arrays[j] = tmp; } //System.out.print(Arrays.toString(scores)); }