为什么我在电脑上代码试验时,使用testSort函数会什么也不显示
#include <iostream> #include "SortTestHelper.h" #include "MergeSort.h" #include "SelectionSort.h" using namespace std; int main() { int n = 600000; int *arr = SortTestHelper::generateRandomArray(n,10,20090); //mergeSort(arr, 10000); SortTestHelper::testSort("mergeSort", mergeSort, arr, n); //SortTestHelper::testSort("selectionSort", selectionSort, arr, n); //SortTestHelper::printArray(arr, 100); delete []arr; return 0; }
将n改小一点就会有显示mergesort使用的时间
void testSort(const string &sortName, void (*sort)(T[], int), T arr[], int n) { T *brr = copyArray(arr, n); clock_t startTime = clock(); sort(brr, n); clock_t endTime = clock(); //cout << sortName << " : " << << " s"<<endl; cout<<sortName<<": "; printf("%.10lf s\n",double(endTime - startTime) / CLOCKS_PER_SEC); assert(isSorted(brr, n)); delete []brr; return; }