C++中计算程序运行的时间,代码如下:
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
clock_t start,finish;
start=clock();
cout << "HW .... " << endl;
finish=clock();
cout << finish-start << "/" << CLOCKS_PER_SEC << " (s) "<< endl;
return 0;
}
本文介绍了一个简单的C++程序,展示了如何使用clock()和CLOCKS_PER_SEC函数来计算程序运行时间,提供了代码实现及运行时间输出。
710

被折叠的 条评论
为什么被折叠?



