【发布时间】:2013-04-19 18:24:06
【问题描述】:
我无法计算 cygwin 中 cpu 处理的时间?这是为什么呢? 我需要一个特殊的命令吗?计算 cpu 中的点击次数是由时钟完成的 包含 time.h 后的函数!
仍然,在我在 Visual Studio 中完成后,我无法在 cygwin 上运行? 为什么会这样!
这里是代码。
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
clock_t t1,t2;
int x=0;
int num;
cout << "0 to get out of program, else, number of iterations" << endl;
cin>>num;
if(num==0)
system(0);
t1=clock();
while (x!=num)
{
cout << "Number "<<x<<" e"<< endl;
if(x%2==0)
cout << "Even" << endl;
else
cout << "Odd" << endl;
x=x+1;
}
t2=clock();
float diff ((float)t2-(float)t1);
cout<<diff<<endl;
float seconds = diff / CLOCKS_PER_SEC;
cout<<seconds<<endl;
system ("pause");
return 0;
}
抱歉英语不好。
【问题讨论】: