算法分析和设计
源代码在线查看: sort.cpp
#include "Sort.h"
#include //DWORD, GetTickCount()
void main()
{
Sort s;
int a[NUM],b[NUM],c[NUM],d[NUM],e[NUM];
srand((unsigned)time(NULL));
for(long i=0;i {
a[i]=rand()*rand()/1000000;
b[i]=c[i]=d[i]=e[i]=a[i];
}
cout DWORD dwStart1 = GetTickCount();
s.BubbleSort(a,NUM);
DWORD dwEnd1 = GetTickCount();
cout
DWORD dwStart2 = GetTickCount();
s.HeapSort(b,NUM);
DWORD dwEnd2 = GetTickCount();
cout
DWORD dwStart3 = GetTickCount();
s.InsertSort(c,NUM);
DWORD dwEnd3 = GetTickCount();
cout
DWORD dwStart4 = GetTickCount();
s.MergeSort(d,NUM);
DWORD dwEnd4 = GetTickCount();
cout
DWORD dwStart5 = GetTickCount();
s.QuickSort(e,0,NUM-1);
DWORD dwEnd5 = GetTickCount();
cout
cout char cs;
cin>>cs;
}