记录程序运行时间
C++下通过引入头文件ctime
通过以下的代码来实现对于时间的记录
clock_t start, time;
start = clock();
...
end = clock();
cout << (double)(start-end)/CLOCKS_PER_SEC << endl;
这对于刚开始学习算法,看每个算法的运行时间来体会算法的高效,是很有帮助的
C++下通过引入头文件ctime
通过以下的代码来实现对于时间的记录
clock_t start, time;
start = clock();
...
end = clock();
cout << (double)(start-end)/CLOCKS_PER_SEC << endl;
这对于刚开始学习算法,看每个算法的运行时间来体会算法的高效,是很有帮助的