package sorttest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BasicSort {
public static void selectionSort(int[] number) {
for (int i = 0; i < number.length - 1; i++) {
int m = i;
for (int j = i + 1; j < number.length; j++)
if (number[j] < number[m])
m = j;
if (i != m)
swap(number, i, m);
}
}
public static void injectionSort(int[] number) {
for (int j = 1; j < number.length; j++) {
int tmp = number[j];
int i = j - 1;
while (tmp < number[i]) {
number[i + 1] = number[i];
i--;
if (i == -1)
break;
}
number[i + 1] = tmp;
}
}
public static void bubbleSort(int[] number) {
boolean flag = true;
for (int i = 0; i < number.length - 1 && flag; i++) {
flag = false;
for (int j = 0; j < number.length - i - 1; j++) {
if (number[j + 1] < number[j]) {
swap(number, j + 1, j);
flag = true;
}
}
}
}
private static void swap(int[] number, int i, int j) {
int t;
t = number[i];
number[i] = number[j];
number[j] = t;
}
public static void main(String[] args){
// int[] arrayint=new int[10];
// int i;
// System.out.println("输入:10 个数字");
// for(i=0;i<arrayint.length;i++){
// BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
// try {
// if(br.readLine()!=null)
// arrayint[i]=Integer.parseInt(br.readLine());
// if(i==arrayint.length-1){
// System.out.println("输入停止");
// }
// } catch (NumberFormatException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
int[] arrayint={1,5,3,4,2,15,10,5,20,11};
selectionSort(arrayint);
//injectionSort(arrayint);
for(int j=0;j<arrayint.length;j++){
System.out.print(arrayint[j]+"|");
}
}
}