Discuz! Board

 找回密码
 立即注册
查看: 638|回复: 0

2022.9.24时钟

[复制链接]

15

主题

19

帖子

4118

积分

论坛元老

Rank: 8Rank: 8

积分
4118

墨海马 Lv:15
发表于 2022-9-24 16:03:05 | 显示全部楼层 |阅读模式
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
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);
}
struct time
{
        int n;
        int y;
        int r;
        int s;
        int f;
        int m;
}a;

int main()
{       
        HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
        a.n=2022;
        a.y=9;
        a.r=30;
        a.s=23;
        a.f=59;
        a.m=58;
        int b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
        while(1)
        {
                a.m++;
                Sleep(1000);
                if(a.m==60)
                {
                        a.f++;
                        a.m=0;
                }
                if(a.f==60)
                {
                        a.s++;
                        a.f=0;
                }
                if(a.s==24)
                {
                        a.s=0;
                        a.r++;
                }
                if(a.r==b[a.y-1]+1)
                {
                        a.y++;
                        a.r=1;
                }
                if(a.y==12)
                {
                        a.n++;
                        a.y=1;
                }
                cout<<setw(2)<<a.n<<"年"<<setw(2)<<a.y<<"月"<<setw(2)<<a.r<<"日"<<setw(2)<<a.s<<':'<<setw(2)<<a.f<<':'<<setw(2)<<a.m;
                gotoxy(hout,0,0);
        }
        return 0;
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-5-30 12:00 , Processed in 0.069887 second(s), 35 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.. 技术支持 by 巅峰设计

快速回复 返回顶部 返回列表