现在的位置: 首页 > 综合 > 正文

秒表计时器

2013年10月22日 ⁄ 综合 ⁄ 共 517字 ⁄ 字号 评论关闭

 #include<iostream.h>
#include<time.h>
#include<conio.h>
class secondwatch
{
public:
 secondwatch()
 {
  itsbegin=itsend=0;
 }
 void start()
 {
  cout<<"请按任意键确定计时开始"<<endl;
  _getch();
  itsbegin=double(clock())/CLOCKS_PER_SEC;
  cout<<"计时开始。。。。"<<endl;
 }
 void end()
 {
  cout<<"请按任意键确定计时结束"<<endl;
  _getch();
  itsend=double(clock())/CLOCKS_PER_SEC;
  cout<<"计时结束!!"<<endl;
 }
 void show()
 {
  cout<<"共耗时"<<(itsend-itsbegin)<<"秒";
  cout<<endl;
 }
private:
 double itsbegin,itsend;
};
int main()
{
 secondwatch s;
 s.start();
 s.end();
 s.show();
 return 0;
}

抱歉!评论已关闭.