|
- <div class="blockcode"><blockquote>#include<bits/stdc++.h>
- #include <windows.h>
- using namespace std;
- int h,m,s,y,mo,d;
- int a[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,
- 31,29,31,30,31,30,31,31,30,31,30,31};
- int rn(int y)
- {
- if(y%4==0&&y%100!=0)
- {
- return 1;
- }
- else if(y%400==0)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- 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()
- {
- system("color 5E");
- HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
- // system("cls");//清屏
- // cout<<1<<'\n';
- // Sleep(1000);
- // gotoxy(hout,0,0);
- // cout<<2<<'\n';
- // return 0;
- h=23;
- m=59;
- s=55;
- y=2001;
- mo=02;
- d=28;
- 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[rn(y)][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);
- }
- }
复制代码
|
|