选择排序
程序员文章站
2022-03-01 15:14:08
...
/**
* @author WenQiang Wu
* @version Dec 28, 2009
*/
public class SelectedSort {
/**
* selected sort
*
* @param value
*/
public static void selectedSort(int[] value) {
for (int i = 0; i < value.length - 1; i++) {
for (int j = i + 1; j < value.length; j++) {
if (value[i] > value[j]) {
int temp = value[i];
value[i] = value[j];
value[j] = temp;
}
}
}
}
/**
* display result
*
* @param value
*/
public static void display(int[] value) {
for (int i = 0; i < value.length; i++) {
System.out.print(value[i] + " ");
}
}
/**
*
* @param args
*/
public static void main(String[] args) {
int[] value = { 12, 8, 3, 59, 132, 1236, 3400, 8, 352, 37 };
selectedSort(value);
display(value);
}
}