Tag:排序

Tag (排序)'s result:

6种排序算法效率比较

刚学C时写的程序,实现了冒泡,选择,插入,希尔,快速和归并排序,并对此6种排序算法进行了简单的效率比较。 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <windows.h> int str1[105],str2[105],str3[105],str4[105],str5[105]; int str1_1[105],str1_2[105],str1_3[105],str1_4[105],str1_5[105],str1_6[105]; int str2_1[105],str2_2[105],str2_3[105],str2_4[105],str2_5[105],str2_6[105]; int str3_1[105],str3_2[105],str3_3[105],str3_4[105],str3_5[105],str3_6[105]; int str4_1[105],str4_2[105],str4_3[105],str4_4[105],str4_5[105],str4_6[105]; int str5_1[105],str5_2[105],str5_3[105],str5_4[105],str5_5[105],str5_6[105]; int k,k1,k2,k3,k4,k5; int qcompare,qmov; int gcompare,gmov; int avbubblingc,avselectc,avinsertionc,avshellc,avquickc,avmergec; int avbubblingm,avselectm,avinsertionm,avshellm,avquickm,avmergem; void randint() //产生随机数数组 { int i,j; srand((unsigned)time(NULL)); for(i=0;i<100;i++) //模型数组 { str1[i]=rand()%101; str2[i]=rand()%101; str3[i]=rand()%101; str4[i]=rand()%101; str5[i]=rand()%101; } for(j=0;j<100;j++) { str1_1[j] = str1[j]; str1_2[j] = str1[j]; str1_3[j] = str1[j]; str1_4[j] = str1[j]; str1_5[j] = str1[j]; str1_6[j] = str1[j]; } for(j=0;j<100;j++) { str2_1[j] = str2[j]; str2_2[j] = str2[j]; str2_3[j] = str2[j]; str2_4[j] = str2[j]; str2_5[j] = str2[j]; str2_6[j] = str2[j]; } for(j=0;j<100;j++) { str3_1[j] = str3[j]; str3_2[j] = str3[j]; str3_3[j] = str3[j]; str3_4[j] = str3[j]; str3_5[j] = str3[j]; str3_6[j] = str3[j]; } for(j=0;j<100;j++) { str4_1[j] = str4[j]; str4_2[j] = str4[j]; str4_3[j] = str4[j]; str4_4[j] = str4[j]; str4_5[j] = str4[j]; str4_6[j] = str4[j]; } for(j=0;j<100;j++) { str5_1[j] = str5[j]; str5_2[j] = str5[j]; str5_3[j] = str5[j]; str5_4[j] = str5[j]; str5_5[j] = str5[j]; str5_6[j] = str5[j]; } } void printrand() //打印生成的随机数组 { int i; printf(“第一组\n”); for(i=0;i<100;i++) { printf(“%d “,str1[i]); } printf(“\n————————————\n”); printf(“第二组\n”); for(i=0;i<100;i++)……