日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数字时钟程序c语言,C语言实现电子时钟程序

發(fā)布時間:2023/12/8 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数字时钟程序c语言,C语言实现电子时钟程序 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本文實例為大家分享了C語言實現(xiàn)電子時鐘程序的具體代碼,供大家參考,具體內(nèi)容如下

Qt 里面運行

#include

#include

#include

#include

#include

typedef struct

{

int x;

int y;

}Point;

time_t now;

struct tm *pt, t1, t2;

int printpoint(Point p)

{

Point p1;

p1.x = p.x + 2; p1.y = p.y + 4;

gotoxy(p1.x, p1.y); printf("%c%c", 2, 2);

gotoxy(p1.x, p1.y + 1); printf("%c%c", 2, 2);

p1.y += 4;

gotoxy(p1.x, p1.y); printf("%c%c", 2, 2);

gotoxy(p1.x, p1.y + 1); printf("%c%c", 2, 2);

return 0;

}

int print0(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else

printf("%c%4s%c", 2, " ", 2);

}

return 0;

}

int print1(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

printf("%5s%c", " ", 2);

}

return 0;

}

int print2(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 6 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else if (i>0 && i<6)

printf("%5s%c", " ", 2);

else

printf("%c", 2);

}

return 0;

}

int print3(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 6 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else

printf("%5s%c", " ", 2);

}

return 0;

}

int print4(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i<6) printf("%c%4s%c", 2, " ", 2);

else if (i == 6)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else printf("%5s%c", " ", 2);

}

return 0;

}

int print5(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 6 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else if (i>0 && i<6)

printf("%c", 2);

else

printf("%5s%c", " ", 2);

}

return 0;

}

int print6(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 6 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else if (i>0 && i<6)

printf("%c", 2);

else

printf("%c%4s%c", 2, " ", 2);

}

return 0;

}

int print7(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0) printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else printf("%5s%c", " ", 2);

}

return 0;

}

int print8(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 6 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else printf("%c%4s%c", 2, " ", 2);

}

return 0;

}

int print9(Point p)

{

int i = 0;

for (; i<13; i++)

{

gotoxy(p.x + 1, p.y + i);

if (i == 0 || i == 6 || i == 12)

printf("%c%c%c%c%c%c", 2, 2, 2, 2, 2, 2);

else if (i>0 && i<6)

printf("%c%4s%c", 2, " ", 2);

else

printf("%5s%c", " ", 2);

}

return 0;

}

int clear(Point p)

{

int i = 0;

for (; i<13; i++)

gotoxy(p.x, p.y + i); printf("%16s", " ");

return 0;

}

int printtime(Point p, int n)

{

int a, b;

Point pp;

a = n / 10, b = n % 10;

pp.x = p.x + 8, pp.y = p.y;

switch (a)

{

case 0: print0(p); break;

case 1: print1(p); break;

case 2: print2(p); break;

case 3: print3(p); break;

case 4: print4(p); break;

case 5: print5(p); break;

}

switch (b)

{

case 0: print0(pp); break;

case 1: print1(pp); break;

case 2: print2(pp); break;

case 3: print3(pp); break;

case 4: print4(pp); break;

case 5: print5(pp); break;

case 6: print6(pp); break;

case 7: print7(pp); break;

case 8: print8(pp); break;

case 9: print9(pp); break;

}

return 0;

}

int main()

{

Point phour, pmin, psec, point1, point2;

phour.x = 9, pmin.x = 32, psec.x = 55;

phour.y = pmin.y = psec.y = 7;

point1.x = 25, point2.x = 49;

point1.y = point2.y = 7;

clrscr();

textbackground(YELLOW); /* 設(shè)置背景顏色*/

textcolor(RED); /* 設(shè)置數(shù)字顯示顏色*/

now = time(0);

pt = localtime(&now);

t1 = *pt;

printtime(phour, t1.tm_hour);

printpoint(point1);

printtime(pmin, t1.tm_min);

printpoint(point2);

printtime(psec, t1.tm_sec);

while (1)

{

now = time(0);

pt = localtime(&now);

t2 = *pt;

if (t2.tm_sec != t1.tm_sec)

{

t1 = t2;

clrscr();

printtime(phour, t1.tm_hour);

printpoint(point1);

printtime(pmin, t1.tm_min);

printpoint(point2);

printtime(psec, t1.tm_sec);

}

if (bioskey(1) == 0) continue;

else exit(0);

}

return 0;

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

時間: 2018-11-16

總結(jié)

以上是生活随笔為你收集整理的数字时钟程序c语言,C语言实现电子时钟程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。