|
#include<bits/stdc++.h>
#include <windows.h>
using namespace std;
int h,m,s,y,mo,d;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
void gotoxy(HANDLE hout, int x, int y);
void gotoxy(HANDLE hout, int x, int y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hout, pos);
};
int main()
{
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
// system("cls");//清屏
// cout<<1<<'\n';
// Sleep(1000);
// gotoxy(hout,0,0);
// cout<<2<<'\n';
// return 0;
h=00;
m=00;
s=00;
y=2022;
mo=10;
d=01;
while(1)
{
s++;
Sleep(100);
if(s==60)
{
m++;
s=0;
}
if(m==60)
{
h++;
m=0;
}
if(h==24)
{
h=0;
m=0;
s=0;
d++;
}
if(d==a[mo-1]+1)
{
mo++;
d=1;
}
if(mo==12)
{
y++;
mo=1;
}
cout<<setw(4)<<y<<"年"<<setw(2)<<mo<<"月"<<setw(2)<<d<<"日"<<setw(2)<<h<<":"<<setw(2)<<m<<":"<<setw(2)<<s;
gotoxy(hout,0,0);
}
}
|
|