Discuz! Board

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

9.22 时钟

[复制链接]

54

主题

66

帖子

574

积分

高级会员

Rank: 4

积分
574
发表于 2022-9-22 19:14:24 | 显示全部楼层 |阅读模式
#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 h,m,s;
        h=19;
        m=59;
        s=59;
        while(1){
                if(s==60){
                        s=0;
                        m+=1;
                }
                if(m==60){
                        m=0;
                        h+=1;
                }
                if(s<=9)
                {
                        if(m<=9)
                        {
                                cout<<h<<":"<<"0"<<m<<":"<<"0"<<s<<endl;
                        }
                        else{
                                cout<<h<<":"<<"0"<<m<<":"<<"0"<<s<<endl;
                        }
                }
                else
                {
                        cout<<h<<":"<<m<<":"<<s<<endl;
                }
                Sleep(1000);
                s+=1;
        gotoxy(hout,0,0);
        }


        return 0;
}

回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-2-13 15:56 , Processed in 0.049136 second(s), 26 queries .

Powered by Discuz! X3.4

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

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