public class BubbleSort {

	public static void main(String[] args) {
		int score[] = { 80, 23, 20, 87, 89, 90, 99, 100 };
		
		for (int i = 0; i < score.length - 1; i++) { 
			for (int j = 0; j < score.length - i - 1; j++) { 
				if (score[j] < score[j + 1]) { 
					int temp = score[j];
					score[j] = score[j + 1];
					score[j + 1] = temp;
				}
			}
			
			System.out.print("第" + (i + 1) + "次排序结果:");
			for (int a = 0; a < score.length; a++) {
				System.out.print(score[a] + "\t");
			}
			System.out.println("");
			
		}
		
		System.out.print("最终排序结果:");
		for (int a = 0; a < score.length; a++) {
			System.out.print(score[a] + "\t");
		}
		
	}

}


本文转载:CSDN博客