- /**
- *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)
- */
用IntelliJ IDEA写Java的冒泡排序
原文:https://www.cnblogs.com/stefango/p/Stefango.html