栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

c语言——做一个简单的计时器/时钟

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

c语言——做一个简单的计时器/时钟

闲来无事看到桌面右下角的时钟,就想仿照做一个数字时钟,小白在此,仅供消遣,大神勿喷O(∩_∩)O~

#include 
#include 
#include 
#include 
#include 

int h,m,s,e,d=0;
void updata();
void display();
void delay();
void gotoxy(int x,int y);

void gotoxy(int x,int y)//将光标移动到坐标为(x,y)的地方
{
    CONSOLE_SCREEN_BUFFER_INFO    csbiInfo;
    HANDLE    hConsoleOut;
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
    csbiInfo.dwCursorPosition.X = x;
    csbiInfo.dwCursorPosition.Y = y;
    SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}


void updata()     //更新秒、分、时
{

    if (s==60)
    {
 s=0;
 m++;
    }
    if (m==60)
    {
 m=0;
 h++;
    }

    if (h==24)
    {
 h=0;
 d++;
 exit (0);
    }
}

void delay()    
 
{
    int i;
    int j;

 for(i=0;i<=100;i++)
 {
     Sleep(9);
     //for(j=0;j<10000000;j++);
     switch(i/10)
     {
  case 0 : printf("bbb0%d)",i);break;
  case 1 :
  case 2 :
  case 3 :
  case 4 :
  case 5 :
  case 6 :
  case 7 :
  case 8 :
  case 9 :printf("bbb%d)",i);break;
  case 10:printf("bbb00)");s++;break;
     }
 }
 printf("ntt╠点击屏幕暂停,按任意键继续ttt    ╣");
 printf("ntt╚─────────────────────────╝");
}

void display()     //显示时间
{
    gotoxy(18,3);   //成败在此一举~~~~
    if(h<10) printf("tt      0%d:",h);
    else printf("ntt╠tt%d:",h);
    if(m<10) printf("0%d:",m);
    else printf("%d:",m);
    if(s<10) printf("0%d",s);
    else printf("%d",s);
    printf("(00)");

}

int main(void)
{
    printf("tt╔┄┄┄┄┄┄┄┄┄*****计时器*****┄┄┄┄┄┄┄┄╗");
    printf("ntt╠**************************************************╣");
    printf("ntt╠时间输入:(时 分 秒)   ╣");
    printf("ntt╠ ╣");
    gotoxy(18,3);
    scanf("%d%d%d",&h,&m,&s);
    while(1)
    {
 display();
 delay();
 updata();
    }
    return 0;
}

okay~小小地兴奋一下下,弄外面这个框框真的很费神啊╮(╯╰)╭
那就到此结束啦,给自己立个flag,继续学习,有朝一日再来喷自己~~(^ω^)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/233640.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号