标签:style blog color ar java for sp div c
java实现
package sort; public class ShellSort { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int[] arr={70,80,31,37,10,1,48,60,33,80}; shellSort(arr); for(int i=0; i<arr.length; i++) System.out.print(arr[i]+" "); } private static void shellSort(int[] arr) { // TODO Auto-generated method stub int i,j,k; int gap,temp; for(gap=arr.length/2; gap>0; gap=gap/2) { for(i=0; i<gap; i++) { for(j=i+gap; j<arr.length; j=j+gap) { if(arr[j]<arr[j-gap]) { temp=arr[j]; arr[j]=arr[j-gap]; arr[j-gap]=temp; } } } } } }
标签:style blog color ar java for sp div c
原文地址:http://www.cnblogs.com/huangcongcong/p/4004137.html