正在加载图片...
void insertsort( RecType ri,int-n)/对R0.,n-1按递增有序进行 直接插入排序* int Rectype temp; for(i=l; i<n; i++) i temp=R; j=i1;/从右向左在有序区R0.i-1找R[的插入位置* while (i>=0 & temp key<riil. key) R+1=Rji;/将关键字大于R[key的记录后移*/ Ri+1temp;/在j+1处插入R[/void InsertSort(RecType R[],int n) /*对R[0..n-1]按递增有序进行 直接插入排序*/ { int i,j; RecType temp; for (i=1;i<n;i++) { temp=R[i]; j=i-1; /*从右向左在有序区R[0..i-1]找R[i]的插入位置*/ while (j>=0 && temp.key<R[j].key) { R[j+1]=R[j]; /*将关键字大于R[i].key的记录后移*/ j--; } R[j+1]=temp; /*在j+1处插入R[i]*/ } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有