献给俺地朋友们

包子环游世界

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
//this code is writen by c++
#include <iostream>
#include 
<ctime>
using namespace std;

class timer{
clock_t start; 
public:
timer(); 
//set new time
~timer(); //distory time() and get new time
}
;
timer::timer()
{
start 
= clock;
}

timer::
~timer()
{
clock_t end;
end
=clock();
cout 
<< "Elapsed time:" << (end-start)/CLOCKS_PER_SEC << endl;
}

int main()
{
timer ob;
char c;
ob.timer();
//for()
//cin >> c;
return 0;
}



the code above teaches me how to measure time in c++;and also there is another way in c,gettimeofday function.
posted on 2004-11-18 15:14  半吊子程序员  阅读(1672)  评论(0编辑  收藏  举报