标签:style blog color ar for sp div log bs
算法导论,插入排序
public class InsertSort { public static double [] sort(double [] num) { for(int i =1; i<num.length;i++) { double temp = num[i]; int j=i-1; while(j>=0 && temp < num[j]) { num[j+1]=num[j]; j--; } num[j+1] = temp; } return num; } public static void main(String[] args) { // TODO Auto-generated method stub double num [] ={1.3, 5 ,2, 6.9, 7.8,4.3}; num = InsertSort.sort(num); for(double a:num) System.out.print(a+" "); } }
标签:style blog color ar for sp div log bs
原文地址:http://www.cnblogs.com/wzm-xu/p/4077186.html