public class BubbleSort{
public static void main(String[] args){
int number[] ={617, 900, 715, 871, 89, 90, 99, 100};
for(int i = 0;i<number.length - 1;i++){//循环所有的number
for(int j = 0;j<number.length - i - 1;j++){
if(number[j] > number[j+1]){
int temp = number[j];
number[j] = number[j+1];
number[j+1] = temp;
}
}
System.out.print("第" + (i + 1) + "次排序结果:");
for(int a = 0; a < number.length; a++){
System.out.print(number[a] + "\t");
}
System.out.println("");
}
System.out.print("最终排序结果:");
for(int a = 0; a < number.length; a++){
System.out.print(number[a] + "\t");
}
public static void main(String[] args){
int number[] ={617, 900, 715, 871, 89, 90, 99, 100};
for(int i = 0;i<number.length - 1;i++){//循环所有的number
for(int j = 0;j<number.length - i - 1;j++){
if(number[j] > number[j+1]){
int temp = number[j];
number[j] = number[j+1];
number[j+1] = temp;
}
}
System.out.print("第" + (i + 1) + "次排序结果:");
for(int a = 0; a < number.length; a++){
System.out.print(number[a] + "\t");
}
System.out.println("");
}
System.out.print("最终排序结果:");
for(int a = 0; a < number.length; a++){
System.out.print(number[a] + "\t");
}
}
}