c++实现每隔1秒钟执行一段程序
#include#includeusing namespace std;int getTime() {return clock()/CLOCKS_PER_SEC;}int main() {int i = 0;int lastTime = 0;while (1) {int now = getTime();if (now - lastTime > 0) {cout &...
·
#include
#include
using namespace std;
int getTime() {
return clock()/CLOCKS_PER_SEC;
}
int main() {
int i = 0;
int lastTime = 0;
while (1) {
int now = getTime();
if (now - lastTime > 0) {
cout << ++i << endl;
lastTime = now;
}
}
return 0;
}
更多推荐
所有评论(0)