#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#define SIZE 900
void Creat(long s1[],long s2[],long s3[]);
void Qsort(int v[],int left,int right); //快速排序
void Swap(int v[],int i,int j); //交换函数
void BubbleSort(int s[]); //冒泡排序
void InsertSort(int s[],int n); //插入排序(从小到大)
int main()
{
long s1[SIZE],s2[SIZE],s3[SIZE];
int i;
clock_t start1,end1,start2,end2,start3,end3;
long double duration1=0.0,duration2=0.0,duration3=0.0;
Creat(s1,s2,s3);
//printf("原数组为:\n");
//for(i=0;i<SIZE;i++)
// printf("s1[%d]=%ld\n",i,s1[i]);
start1=clock(); //快速排序开始时间
Qsort(s1,0,SIZE); //快速排序
end1=clock(); //快速排序结束时间
duration1=(double)(end1-start1)/CLOCKS_PER_SEC;; //快速排序时间差(秒)
printf("Quick Sort:%f\n",duration1);
start2=clock(); //冒泡排序开始时间
BubbleSort(s2);
end2=clock(); //冒泡排序结束时间
duration2=(double)(end2-start2)/CLOCKS_PER_SEC; //冒泡排序时间差(秒)
printf("Bubble Sort:%f\n",duration2);
start3=clock(); //插入排序开始时间
InsertSort(s3,SIZE);
end3=clock(); //插入排序结束时间
duration3=(double)(end3-start3)/CLOCKS_PER_SEC; //插入排序时间差(秒)
printf("Insert Sort:%f\n",duration3);
#include<stdlib.h>
#include<math.h>
#include<time.h>
#define SIZE 900
void Creat(long s1[],long s2[],long s3[]);
void Qsort(int v[],int left,int right); //快速排序
void Swap(int v[],int i,int j); //交换函数
void BubbleSort(int s[]); //冒泡排序
void InsertSort(int s[],int n); //插入排序(从小到大)
int main()
{
long s1[SIZE],s2[SIZE],s3[SIZE];
int i;
clock_t start1,end1,start2,end2,start3,end3;
long double duration1=0.0,duration2=0.0,duration3=0.0;
Creat(s1,s2,s3);
//printf("原数组为:\n");
//for(i=0;i<SIZE;i++)
// printf("s1[%d]=%ld\n",i,s1[i]);
start1=clock(); //快速排序开始时间
Qsort(s1,0,SIZE); //快速排序
end1=clock(); //快速排序结束时间
duration1=(double)(end1-start1)/CLOCKS_PER_SEC;; //快速排序时间差(秒)
printf("Quick Sort:%f\n",duration1);
start2=clock(); //冒泡排序开始时间
BubbleSort(s2);
end2=clock(); //冒泡排序结束时间
duration2=(double)(end2-start2)/CLOCKS_PER_SEC; //冒泡排序时间差(秒)
printf("Bubble Sort:%f\n",duration2);
start3=clock(); //插入排序开始时间
InsertSort(s3,SIZE);
end3=clock(); //插入排序结束时间
duration3=(double)(end3-start3)/CLOCKS_PER_SEC; //插入排序时间差(秒)
printf("Insert Sort:%f\n",duration3);

