C++實現以秒為單位的計數器 阿新 • • 發佈:2020-12-28 技術標籤:c++c++ #include<iostream> #include<ctime> using namespace std; int main(void) { clock_t start= clock(); size_t ss = 0; while (1) { if ((double)(clock()- start) / 1000.0 >= 1.0) { start= clock(); cout << ss++ << endl; if (ss >= 100000) { ss = 0; } } } return 0; }