63,579
社区成员




#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;
void showtime(tm* pt)
{
cout<<setfill('0')<<1900 + pt->tm_year<<'-';
cout<<setw(2)<<pt->tm_mon + 1<<'-';
cout<<setw(2)<<pt->tm_mday<<' ';
cout<<setw(2)<<pt->tm_hour<<':';
cout<<setw(2)<<pt->tm_min<<':';
cout<<setw(2)<<pt->tm_sec<<'\n';
}
int main()
{
time_t t = time(NULL);
tm* pt = localtime(&t);
int sec = pt->tm_sec;
showtime(pt);
while(1)
{
t = time(NULL);
pt = localtime(&t);
if(sec != pt->tm_sec)
{
sec = pt->tm_sec;
system("cls");
showtime(pt);
}
}
return 0;
}