计时器
2026-03-22 19:48:54
发布于:浙江
代码:
#include <iostream>
#include <thread>
#include <chrono>
using namespace std;
int main() {
int seconds = 0;
while (true) {
seconds++;
if (seconds % 3600 == 0) {
cout << "已经过 " << seconds / 3600 << " 小时" << endl;
} else if (seconds % 60 == 0) {
cout << "已经过 " << seconds / 60 << " 分" << endl;
} else {
cout << "已经过 " << seconds << " 秒" << endl;
}
this_thread::sleep_for(chrono::seconds(1));
}
return 0;
}
全部评论 3
挺好的
2026-03-24 来自 浙江
0d
2026-03-24 来自 浙江
01
2026-03-24 来自 浙江
0

































有帮助,赞一个