求C语言测试排序代码

来源:百度知道 编辑:UC知道 时间:2024/05/29 08:18:27
要求如下:
1、用C语言实现插入排序、合并排序和快速排序算法;
2、随机产生整数测试所实现的算法,度量输入规模为10、100、1000、10000、100000和1百万时以上算法的实际运行时间;
没法对20以上规模排序啊

我只有C++版本的:

#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;

/**//******************************************Quick sort *******************************/
template <class T>
int partition(T entry[], int low, int high)
{
T pivot;
int i, // used to scan through the list
last_small; // position of the last key less than pivot
swap(entry[low], entry[(low + high) / 2]);
pivot = entry[low]; // First entry is now pivot.
last_small = low;
for (i = low + 1; i <= high; i++)
if (entry[i] < pivot) {
last_small = last_small + 1;
swap(entry[last_small], entry[i]); // Move large entry to right and small to left.
}
swap(entry[low], entry[last_small]); // Put the pivot into its proper position.
return last_small;
}

template <class