/** *Created by xuzili at 9:38 PM on 2/3/2018 */ public class bubble { public static void main(String[] args) { int[] a = new int[]{9, 6, 8, 3, 0, 1}; ...
- /**
- *Created by xuzili at 9:38 PM on 2/3/2018
- */
- public class bubble {
- public static void main(String[] args) {
- int[] a = new int[]{9, 6, 8, 3, 0, 1};
- int i, j, t;
- for (i = 0; i < a.length - 1; i++)
- for (j = 0; j < a.length - i- 1; j++)
- if (a[j] > a[j + 1]) {
- t = a[j];
- a[j] = a[j + 1];
- a[j + 1] = t;
- }
- for (i = 0; i < a.length; i++)
- System.out.print(a[i]);
- System.out.println("\n--------華麗的分割線--------");
- for(int num:a)
- System.out.println(num);
- }
- }
- /*
- System.out.println();在IntelliJ的快捷鍵為sout
- main函數在IntelliJ的快捷鍵為psvm(即為public static void main)
- */