The feature of this series of blogs is--give the results of each order
Originally wanted to write a good process, get a picture of what, but think online analysis too much, are better, so these blog even if it is a summary of their own it.
#include <stdio.h>void shellsort (int *m, int n) {int i,flag,gap;for (gap=n;gap!=1;) {gap/=2;do {flag=0;for (i=0;i <n-gap;i++) if (M[i]>m[i+gap]) {m[i]=m[i]^m[i+gap];m[i+gap]=m[i]^m[i+gap];m[i]=m[i]^m[i+gap];flag=1;}} while (flag!=0), for (int t=0;t<10;t++) printf ("%d", m[t]);p rintf ("\ n");}} int main () {int i;int a[10]={2,8,5,7,4,3,1,9,6,10};for (i=0;i<10;i++) printf ("%d", A[i]);p rintf ("\ n \ n"); Shellsort (a,10), for (i=0;i<10;i++) printf ("%d", A[i]);p rintf ("\ n"); return 0;}
Run results
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/1F/wKioL1VAkT-gS5zlAAD2UGXYqio556.jpg "title=" 1.jpg " alt= "Wkiol1vakt-gs5zlaad2ugxyqio556.jpg"/>
This article is from the "hacker" blog, make sure to keep this source http://anglecode.blog.51cto.com/5628271/1640369
Sorting Algorithm Big Collection _ Insert Class--Hill (shell) sort