Discuz! Board

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

时钟

[复制链接]

51

主题

54

帖子

8724

积分

论坛元老

Rank: 8Rank: 8

积分
8724

大牙狸 Lv:12
发表于 2022-9-29 19:33:30 | 显示全部楼层 |阅读模式
#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);
};

int main()
{
    HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
        int a=23,f=59,s=30,y=2022,m=1,d=30,n[12]={31,28,31,30,31,30,31,31,30,31,30,31};
        while(1)
        {        
                s++;
                if(s==60)
                {
                        s=0;
                        f++;
                        if(f==60)
                        {
                                f=0;
                                a++;
                                if(a==24)
                                {
                                        a=1;
                                        d++;
                                        if(d==n[m-1])
                                        {
                                                d=1;
                                                m++;
                                                if(m==12)
                                                {
                                                        m=1;
                                                        y++;
                                                }
                                        }
                                }
                }        }

                cout<<y<<"年"<<m<<"月"<<d<<"日"<<setw(2)<<a<<":"<<setw(2)<<f<<":"<<setw(2)<<s<<endl;
        Sleep(100);
        gotoxy(hout,0,0);
        }       
        return 0;
}
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-7-18 11:51 , Processed in 0.053038 second(s), 23 queries .

Powered by Discuz! X3.4

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

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