public class Tes {
public static void main(String[] args) {
/*define an int array*/
int[] num = {3, 24, 23, 3, 1, 25, 346, 36, 36, 36, 23, 2, 2536, 47, 47};
int len = num.length;
/* print the array before the select*/
print(len,num);
/*set a flag as the circle flag*/
boolean flag = true;
while ( flag ) {
flag = false;
for (int i = 0; i < len - 1 ; i ++) {
if (num[i] > num[i + 1]) {
int tem = num[i + 1];
num[i + 1] = num[i];
num[i] = tem;
flag = true;
}
}
}
print(len,num);
}
/* static method to print an array*/
public static void print (int len, int[] num){
System.out.println("当前数组是:");
for (int j = 0; j < len; j++) {
System.out.print(num[j] + " ");
}
System.out.println();
}
}