=i;j--)if(r[j"> =i;j--)if(r[j" />
欢迎来到天天文库
浏览记录
ID:13822627
大小:29.50 KB
页数:8页
时间:2018-07-24
《内部数据排序参考》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、内部数据排序参考#include"stdio.h"#defineN10//冒泡排序voidbublesort(int*r){inti,j;inttemp;for(i=0;i=i;j--)if(r[j+1]2、k];r[k]=temp;}}}//直接插入排序voidinsertsort(int*r2){inti,j;for(i=2;i<=N;i++){r2[0]=r2[i];j=i-1;while(r2[0]=r[i])i3、++;r[j]=r[i];}r[i]=temp;if(start=1;d=d/2)for(i=1+d;i<=N;i++){r2[0]=r2[i];j=i-d;while(j>0&&r2[0]4、p;temp=r2[i];j=2*i;while(j<=m){if(j=1;i--)sift(r2,i,N);for(i=N;i>=2;i--){temp=r2[1];r2[1]=r2[i];r2[i]=temp;sift(r2,1,i-1);}}//归并排序voidmerge(int*r,intlow,intm,inthigh5、){intr1[N];inti,j,k;i=low;j=m+1;k=0;while(i<=m&&j<=high)if(r[i]<=r[j]){r1[k]=r[i];i++;k++;}else{r1[k]=r[j];j++;k++;}while(i<=m){r1[k]=r[i];i++;k++;}while(j<=high){r1[k]=r[j];j++;k++;}for(i=low,k=0;i<=high;i++,k++)r[i]=r1[k];}voidmerge_one(int*r,intlenth,intn){inti=0;while(i+2*lenth-16、(r,i,i+lenth-1,i+2*lenth-1);i=i+2*lenth;}if(i+lenth-17、1:case2:case3:case4:{printf("从键盘输入%d个整数:",N);for(i=0;i
2、k];r[k]=temp;}}}//直接插入排序voidinsertsort(int*r2){inti,j;for(i=2;i<=N;i++){r2[0]=r2[i];j=i-1;while(r2[0]=r[i])i
3、++;r[j]=r[i];}r[i]=temp;if(start=1;d=d/2)for(i=1+d;i<=N;i++){r2[0]=r2[i];j=i-d;while(j>0&&r2[0]4、p;temp=r2[i];j=2*i;while(j<=m){if(j=1;i--)sift(r2,i,N);for(i=N;i>=2;i--){temp=r2[1];r2[1]=r2[i];r2[i]=temp;sift(r2,1,i-1);}}//归并排序voidmerge(int*r,intlow,intm,inthigh5、){intr1[N];inti,j,k;i=low;j=m+1;k=0;while(i<=m&&j<=high)if(r[i]<=r[j]){r1[k]=r[i];i++;k++;}else{r1[k]=r[j];j++;k++;}while(i<=m){r1[k]=r[i];i++;k++;}while(j<=high){r1[k]=r[j];j++;k++;}for(i=low,k=0;i<=high;i++,k++)r[i]=r1[k];}voidmerge_one(int*r,intlenth,intn){inti=0;while(i+2*lenth-16、(r,i,i+lenth-1,i+2*lenth-1);i=i+2*lenth;}if(i+lenth-17、1:case2:case3:case4:{printf("从键盘输入%d个整数:",N);for(i=0;i
4、p;temp=r2[i];j=2*i;while(j<=m){if(j=1;i--)sift(r2,i,N);for(i=N;i>=2;i--){temp=r2[1];r2[1]=r2[i];r2[i]=temp;sift(r2,1,i-1);}}//归并排序voidmerge(int*r,intlow,intm,inthigh
5、){intr1[N];inti,j,k;i=low;j=m+1;k=0;while(i<=m&&j<=high)if(r[i]<=r[j]){r1[k]=r[i];i++;k++;}else{r1[k]=r[j];j++;k++;}while(i<=m){r1[k]=r[i];i++;k++;}while(j<=high){r1[k]=r[j];j++;k++;}for(i=low,k=0;i<=high;i++,k++)r[i]=r1[k];}voidmerge_one(int*r,intlenth,intn){inti=0;while(i+2*lenth-16、(r,i,i+lenth-1,i+2*lenth-1);i=i+2*lenth;}if(i+lenth-17、1:case2:case3:case4:{printf("从键盘输入%d个整数:",N);for(i=0;i
6、(r,i,i+lenth-1,i+2*lenth-1);i=i+2*lenth;}if(i+lenth-17、1:case2:case3:case4:{printf("从键盘输入%d个整数:",N);for(i=0;i
7、1:case2:case3:case4:{printf("从键盘输入%d个整数:",N);for(i=0;i
此文档下载收益归作者所有