标签:sort 技术分享 rgs 排序算法 blog for oid color out
package com.jckb; /** * 冒泡排序 * @author gx */ public class BubbleSort { public static void main(String[] args) { int[] arr = { 6, 3, 8, 2, 9, 1 }; for (int i = 0; i < arr.length - 1; i++) { for (int j = 0; j < arr.length - 1 - i; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } System.out.println("排序后的数组为:"); for (int item : arr) { System.out.print(item + "\t"); } } }
//冒泡排序过程图
标签:sort 技术分享 rgs 排序算法 blog for oid color out
原文地址:http://www.cnblogs.com/gx-java/p/6235040.html