c语言实现数组排序概要1.docx

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
c语言实现数组排序概要1

主函数测试 #includestdio.h #includestdlib.h #includetime.h #include Sort.h void main() { int i, s, j, n; double sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0, sum5 = 0, sum6 = 0; double dif; double avg1, avg2, avg3, avg4, avg5, avg6; time_t start,end; srand((unsigned)time(NULL)); printf(请输入一个30000到300000的整数:); while(true){ scanf(%d,n); DataType *a1 = (DataType *)malloc(sizeof(DataType) *n); DataType *a2 = (DataType *)malloc(sizeof(DataType) *n); DataType *a3 = (DataType *)malloc(sizeof(DataType) *n); DataType *a4 = (DataType *)malloc(sizeof(DataType) *n); DataType *a5 = (DataType *)malloc(sizeof(DataType) *n); DataType *a6 = (DataType *)malloc(sizeof(DataType) *n); if(n = 30000 n = 300000) { for(j = 0; j 10; j++ ) { for(i = 0; i n; i++) { s = rand(); a1[i].key = s; a2[i].key=a1[i].key; a3[i].key=a1[i].key; a4[i].key=a1[i].key; a5[i].key=a1[i].key; a6[i].key=a1[i].key; } printf(*****************************************************************\n); //冒泡排序测试 start = clock(); BubbleSort(a1,n-1); end = clock(); dif= (end-start)/1000.00; sum1=(end-start)/1000.00 + sum1; printf(BubbleSort: %.8f\n,dif); avg1 = sum1/10; //快速排序测试 start = clock(); QuickSort(a2,0,n-1); end = clock(); dif= (end-start)/1000.00; sum2=(end-start)/1000.00 + sum2; printf(QuickSort: %.8f\n,dif); avg2 = sum2/10; //插入排序测试 start = clock(); InsertSort(a3,n); end = clock(); dif= (end-start)/1000.00; sum3=(end-start)/1000.00 + sum3; printf(InsertSort: %.8f\n,dif); avg3 = sum3/10; //选择排序测试 start = clock(); SelectSort(a4,n); end = clock(); dif= (end-start)/1000.00; sum4=(end-start)/1000.00 + sum4; printf(SelectSort: %.8f\n,dif); avg4 = sum4/10; //堆排序测试 start = clock(); HeapSort(a5, n); end = clock(); dif= (end-start)/1000.00; sum5=(end-start)/1000.0

文档评论(0)

yaocen + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档