#include <iostream> #include<stdlib.h> #include<windows.h> #include<string> using namespace std; int main() { string week = " "; while (1) { SYSTEMTIME systemTime; GetLocalTime(&systemTime); cout << "当前时间是:" << systemTime.wYear << "年" << systemTime.wMonth << "月" << systemTime.wDay << "日"; cout << systemTime.wHour << "时" << systemTime.wMinute << "分" << systemTime.wSecond << "秒"; switch (systemTime.wDayOfWeek) { case 0: week = "日"; break; case 1: week = "一"; break; case 2: week = "二"; break; case 3: week = "三"; break; case 4: week = "四"; break; case 5: week = "五"; break; case 6: week = "六"; break; } cout << " 星期"; cout << week << endl; Sleep(1000); system("cls"); } return 0; }