package com;
public class Main {
public static void main(String[] args) {
int teep;
int[]arrays={1,4,2,3,9,5,6};
for(int i=0;i<arrays.length-1;i++){
for(int j=arrays.length-1;j>i;j--){
if(arrays[j]<arrays[j-1]){
teep = arrays[j];
arrays[j] = arrays[j-1];
arrays[j-1] = teep;
}
}
}
//遍历输出排序后的数组
for(int i=0;i<arrays.length;i++){
System.out.println("从小到大的顺序是:"+arrays[i]);
}
}
}
原文地址:https://www.cnblogs.com/hzp0619/p/8831531.html
时间: 2024-10-07 04:05:45