标签:
package com.zc.manythread; /** * 插入排序 * @author 偶my耶 * */ public class InsertionSort { public static void insertion_sort(int[] data) {// for (int i = 1; i < data.length; i++) { if (data[i - 1] > data[i]) { int temp = data[i]; int j = i; while (j > 0 && data[j - 1] > temp) { data[j] = data[j - 1]; j--; } data[j] = temp; } } } public static void main(String[] args) { int[] data = { 6, 2, 4, 1, 5, 9 }; insertion_sort(data); for (int i = 0; i < data.length; i++) { System.out.print(data[i] + "\t"); } } }
标签:
原文地址:http://www.cnblogs.com/oumyye/p/4214169.html