欢迎来到天天文库
浏览记录
ID:55868418
大小:111.00 KB
页数:6页
时间:2020-06-11
《测量各排序法的时间性能.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验坏境,VC++6.0实验程序如下:#include#include#include#includeusingnamespacestd;voidBubbleSort(intr[],intn);//起泡排序voidSelectSort(intr[],intn);//简单选择排序voidQuickSort(intr[],intfirst,intend);//快速排序voidMergeSort1(intr[],intr1[],intn);//归并
2、排序的非递归算法voidMergeSort2(intr[],intr1[],intr2[],ints,intt);//归并排序的递归算法constintsize=100000;intmax=10000000,num[size];intg1[size];inth1[size];inth2[size];intmain(){//数组中的数据随机生成srand((unsigned)time(NULL));//cout<<"随机数组为:";for(inti=0;i3、out<4、0];for(intj=0;j<1000;j++)b[j]=j+10;for(intk=0;k<10000;k++)c[k]=k+5;clock_tstart,end;cout<<"起泡排序结果为:";/*start=clock();BubbleSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<5、etimewas:"<<(double)(end-start)/CLK_TCK<6、序结果为:";/*start=clock();SelectSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<7、<"Thetimewas:"<<(double)(end-start)/CLK_TCK<8、)/CLK_TCK<
3、out<4、0];for(intj=0;j<1000;j++)b[j]=j+10;for(intk=0;k<10000;k++)c[k]=k+5;clock_tstart,end;cout<<"起泡排序结果为:";/*start=clock();BubbleSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<5、etimewas:"<<(double)(end-start)/CLK_TCK<6、序结果为:";/*start=clock();SelectSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<7、<"Thetimewas:"<<(double)(end-start)/CLK_TCK<8、)/CLK_TCK<
4、0];for(intj=0;j<1000;j++)b[j]=j+10;for(intk=0;k<10000;k++)c[k]=k+5;clock_tstart,end;cout<<"起泡排序结果为:";/*start=clock();BubbleSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<5、etimewas:"<<(double)(end-start)/CLK_TCK<6、序结果为:";/*start=clock();SelectSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<7、<"Thetimewas:"<<(double)(end-start)/CLK_TCK<8、)/CLK_TCK<
5、etimewas:"<<(double)(end-start)/CLK_TCK<6、序结果为:";/*start=clock();SelectSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<7、<"Thetimewas:"<<(double)(end-start)/CLK_TCK<8、)/CLK_TCK<
6、序结果为:";/*start=clock();SelectSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<7、<"Thetimewas:"<<(double)(end-start)/CLK_TCK<8、)/CLK_TCK<
7、<"Thetimewas:"<<(double)(end-start)/CLK_TCK<8、)/CLK_TCK<
8、)/CLK_TCK<
此文档下载收益归作者所有