#include <chrono>
#include <iostream>
#include <thread>
int main()
{
auto t0 = std::chrono::steady_clock::now();
for (size_t cnt = 1;; ++cnt)
{
std::cout << cnt << std::endl;
std::this_thread::sleep_until
(
t0 + std::chrono::duration_cast<std::chrono::steady_clock::duration>
(
std::chrono::milliseconds(size_t(1000) * cnt)
)
);
}
return 0;
}
C++中使用<chrono>和<thread>实现秒表
最新推荐文章于 2022-08-04 11:53:51 发布