全部代码如下:
==============================================
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <fstream>
using namespace std;
class Timer
{ clock_t start_time;
public:
Timer(){start_time=clock();}
void elaspe()
/*计算时间*/
{
clock_t end_time=clock();
cout<<"It takes "<<(double)(end_time-start_time)/(double)CLK_TCK<<"seconds\n";
}
/*时间归零*/
void reset(){start_time=clock();}
};
template<class T>
class CCompositor
{
T *a;
public:
CCompositor(){a=NULL;}
~CCompositor(){delete []a;}
void FileMenu();
void Initional(int i);
void GetFile(ifstream&is,int size);
void doCompose(int n);
void sort_1();
void sort_2();
void sort_3();
void sort_4();
};
typedef void (CCompositor<T>::*sort)();
sort g_x[] = {CCompositor<T>::sort_1, CCompositor<T>::sort_2, CCompositor<T>::sort_3, CCompositor<T>::sort_4};
struct SortStruct
{
int m_iIndex; //索引
char* m_pChoice; //文件类型
char* m_pFile; //文件路径
int m_iInfoSize; //文件大小
};
SortStruct sortArr[]={
1, " 1. 数据长度20个, 顺序\n", "order20.txt", 20,
2, " 2. 数据长度200个, 顺序\n", "order200.txt", 200,
3, " 3. 数据长度2000个, 顺序\n", "order2000.txt", 2000,
4, " 4. 数据长度20个, 逆序\n", "unOrder20.txt", 20,
5, " 5. 数据长度200个, 逆序\n", "unOrder200.txt", 200,
6, " 6. 数据长度2000个, 逆序\n", "unOrder2000.txt", 2000,
7, " 7. 数据长度20个, 随机\n", "noOrder20.txt", 20,
8, " 8. 数据长度200个, 随机\n", "noOrder200.txt", 200,
9, " 9. 数据长度2000个, 随机\n", "noOrder2000.txt", 2000,
10," 10.数据长度20个, 部分排序\n","partlyOrder20.txt", 20,
11," 11.数据长度200个, 部分排序\n","partlyOrder200.txt", 200,
12," 12.数据长度200个, 部分排序\n","partlyOrder2000.txt", 2000,
};
void CCompositor<T>::sort_1()
{ //增加代码,完成你的算法
}
void CCompositor<T>::sort_2()
{ //增加代码,完成你的算法
}
void CCompositor<T>::sort_3()
{ //增加代码,完成你的算法
}
void CCompositor<T>::sort_4()
{ //增加代码,完成你的算法
}
void CComp