#include "stdafx.h"
#include <iostream>
using namespace std;
class timekeeper{
private:
DWORD a;
public:
void start();
void stop();
};
void timekeeper::start(){
a=GetTickCount();
}
void timekeeper::stop(){
a=GetTickCount()-a;
cout<<"\n"<<a<<"ms"<<endl;
}
void main()
{
timekeeper timer;
timer.start();
for (int i = 0; i <= 10000; i++){
printf("*");
}
timer.stop();
}c++计时函数
最新推荐文章于 2021-12-09 21:21:17 发布
本文介绍了一个简单的C++程序,用于实现一个基本的时间记录器。该程序利用了Windows API中的GetTickCount函数来获取时间戳,并通过自定义类的方法启动和停止计时,最后输出消耗的毫秒数。
1737

被折叠的 条评论
为什么被折叠?



