package sort;
/**
* Created by ozc on 2018/3/14.
*
* @author ozc
* @version 1.0
*/
public class SelectionSort {
public void sort() {
int[] arrays = {2, 3, 1, 4, 3, 5, 1, 6, 1, 2, 3, 7, 2, 3};
/*
//max
int max = 0;
for (int i = 0; i < arrays.length ; i++) {
if (arrays[i] > max) {
max = arrays[i];
}
}
//
int temp;
temp = arrays[11];
arrays[11] = arrays[13];
arrays[13] = temp;
int max2 = 0;
for (int i = 0; i < (arrays.length - 1); i++) {
if (arrays[i] > max2) {
max2 = arrays[i];
}
}
temp = arrays[7];
arrays[7] = arrays[12];
arrays[12] = temp;
*/
//
int pos ;
//
int temp;
//
for (int i = 0; i < arrays.length - 1; i++) {
//0
pos = 0;
//
for (int j = 0; j < arrays.length - i; j++) {
if (arrays[j] > arrays[pos]) {
pos = j;
}
}
//
temp = arrays[pos];
arrays[pos] = arrays[arrays.length - 1 - i];
arrays[arrays.length - 1 - i] = temp;
}
System.out.println("Java3y" + arrays);
}
}