70.打印时分秒时钟,隔1秒刷新1次屏幕

 1 //做一个时分秒时钟
 2 
 3 #include <iostream>
 4 #include <time.h>
 5 
 6 #include <process.h>
 7 #include <windows.h>
 8 
 9 #include <iomanip>
10 using namespace std;
11 
12 int main()
13 {
14     time_t t;
15     struct tm* tt;
16     while(1)
17     {
18        time(&t);
19        tt = localtime(&t);
20       // printf("%02d:%02d:%02d
",tt->tm_hour,tt->tm_min,tt->tm_sec);//c
21        cout<<setfill('0')<<setw(2)<<tt->tm_hour<<":"<<setw(2)<<tt->tm_min<<":"<<setw(2)<<tt->tm_sec<<endl;//c++
22        Sleep(1000);
23        system("cls");
24     }
25     cout << t << endl;
26     return 0;
27 }
原文地址:https://www.cnblogs.com/ZhuLuoJiGongYuan/p/9578347.html