标签:for [] 结果 ons mini print ++ int system
package algorithm;
public class SelectionSort {
public static void selectionSort(int[] arr) {
if (null == arr || arr.length <= 0) {
return;
}
for (int i = 0; i < arr.length - 1; i++) {
int minIndex = i;
for (int j = i + 1; j < arr.length; j++) {
if (arr[minIndex] > arr[j]) {
minIndex = j;
}
}
int temp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
}
print(arr);
}
private static void print(int[] arr) {
for (int e : arr) {
System.out.print(e + " ");
}
}
public static void main(String[] args) {
int[] arr = {13, 7, 5, 8, 64, 2, 4, 62, 0, 1};
selectionSort(arr);
}
}
标签:for [] 结果 ons mini print ++ int system
原文地址:https://www.cnblogs.com/wangzaiplus/p/10663797.html