前面的数以次与后面的进行比较,大的换到后面。
int[] score = {89,90,78,88,67};
for (int i = 0 ; i < score1.length-1 ; i++){
for (int j = i + 1 ; j < score1.length ; j++){
if (score1[i] > score1[j]){
int temp =score1[i];
score1[i] = score1[j];
score1[j]=temp;
}
}
}
System.out.println(Arrays.toString(score1)); // 数组打印
数组打印 需要导包
import java.util.Arrays;