⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctimer.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 CPP
字号:
#include "ctimer.h"#include <time.h>void CTimer::Reset()// postcondition: all history of timer use erased//                (cumulative will return 0)     {    myCumulative = 0.0;}void CTimer::Start()// postcondition: timer started     {    myStartTime = clock();}void CTimer::Stop()// postcondition: timer stopped     {    myEndTime = clock();    myElapsed = myEndTime - myStartTime;   // time since last start    myCumulative += myElapsed;             // add to cumulative time}    double CTimer::ElapsedTime()// postcondition: returns time between last stop and start     {    return myElapsed/CLOCKS_PER_SEC;}double CTimer::CumulativeTime()// postcondition: returns time timer has been active (last stop)     {    return myCumulative/CLOCKS_PER_SEC;}CTimer::CTimer() : myElapsed(0.0), myCumulative(0.0){    static int firstTime = 0;    if (firstTime == 0){	(void) clock();       // start up clock first time	firstTime = 1;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -