展会信息港展会大全

c++实现每隔1秒钟执行一段程序
来源:互联网   发布日期:2016-01-26 10:28:22   浏览:2388次  

导读: include iostream include ctimeusing namespace std;int getTime() {return clock() CLOCKS_PER_SEC;}int main() {int i = 0;int lastTime = 0;while (1) {int now = getTime();if ( ...

#include <iostream>

#include <ctime>

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;

}

赞助本站

人工智能实验室

相关热词: c++

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港