//折半插入排序 void InsertSort2(int R[],int n) { int i,j,low,mid,hight; for(i=2;i<=n;++i) { R[0]=R[i]; low=1; hight=i-1; while(low<=hight) { mid=(low+hight)/2; if(R[mid]>R[0]) hight=mid-1; else if(R[mid]<R[0]) low=mid+1; else break; } for(j=i-1;j>=hight+1;--j) { R[j+1]=R[j]; } R[hight+1]=R[0]; } }