所需头文件 #include <ctime> 计时起点 clock_t start, finish; double duration; /* 测量一个事件持续的时间*/ start = clock(); 计时结束 finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; cout << "排序所用时间:"; printf("%f seconds\n", duration);