#include<iostream.h>
#include<time.h>
#include<conio.h>
class watch
{
double begin;
double end;
public:
watch()
{
begin=0;
end=0;
}
watch(clock_t t)
{
cout<<”***begin***”<<endl;
begin=(double)t/CLK_TCK;
}
void start()
{
cout<<”***begin***”;
begin=(double)clock()/CLK_TCK;
}
void stop()
{
time_t t;
t=time(NULL);
cout<<"***stop***";
cout<<ctime(&t);end=(double)clock()/CLK_TCK; //CLK_TCK
show(); //是 time.h
} //库中的常数,除以该
// 数,目的是把时钟数转换为秒数。
void show()
{
cout<<"the lasting time:"<<end-begin
<<"seconds";
}
};
void main()
{
watch t;
t.start();