将其以从小到大的顺序排列
Paste_Image.pngpublic class Sequential_sort {
public static void main(String[] args) {
int arr[] = new int[] { 12, 36, 48, 60, 72, 84, 96, 3, 1, 5 };
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] > arr[j]) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
System.out.println(Arrays.toString(arr));
}
}
网友评论