public static void main(String[] args) {
int[] arr={67,45,9,56,34,97,45,18,4,78,90,345,54,2,34,98};
//冒泡排序法 从小到大
for (int i = 0; i < arr.length-1; i++) {
for (int j = 0; j < arr.length-1-i; j++) { //减i是什么意思啊
if(arr[j]>arr[j+1]){
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
|
|