/**
* 选择法排序
* @author Jet
*
*/
public class Order {
public static void main(String[] args) {
int[] a = { 20, 30, 10, 50, 40, 60, 70, 80, 90, 100 };
int index = 0;
int temp = 0;
for (int j = 0; j < a.length; j++) {
int max = a[j];
int i = j;
while (i < a.length - 1) {
if (max < a[i + 1]) {
max = a[i + 1];
index = i + 1;
}
i++;
}
temp = a[index];
a[index] = a[j];
a[j] = temp;
}
for (int m : a) {
System.out.print(m+" ");
}
}
}
* 选择法排序
* @author Jet
*
*/
public class Order {
public static void main(String[] args) {
int[] a = { 20, 30, 10, 50, 40, 60, 70, 80, 90, 100 };
int index = 0;
int temp = 0;
for (int j = 0; j < a.length; j++) {
int max = a[j];
int i = j;
while (i < a.length - 1) {
if (max < a[i + 1]) {
max = a[i + 1];
index = i + 1;
}
i++;
}
temp = a[index];
a[index] = a[j];
a[j] = temp;
}
for (int m : a) {
System.out.print(m+" ");
}
}
}