public class InterSortText {
public static void main(String[] args) {
int arr[] = {7, 5, 3, 2, 4};
for (int i = 1; i < arr.length; i++) {
for (int j = i; j > 0; j--) {
if (arr[j] < arr[j - 1]) {
int temp = arr[j - 1];
arr[j - 1] = arr[j];
arr[j] = temp;
} else {
break;
}
}
}
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i]+ " ");
}
System.out.println();
}
}
转载请注明原文地址:https://blackberry.8miu.com/read-1753.html