本文实例为大家分享了C语言实现电子时钟程序的具体代码,供大家参考,具体内容如下

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); /* 设置背景颜色*/

textcolor(RED); /* 设置数字显示颜色*/

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;

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

时间: 2018-11-16

数字时钟程序c语言,C语言实现电子时钟程序相关推荐

  1. 单片机c语言编程 时钟加日历转换,基于52单片机电子时钟日历系统的设计

    该系统是以52单片机为基础,以时钟日历芯片DSl2887为核心构建的时钟系统.完成的功能如下:显示年.月.日.星期.小时.分钟.秒钟,具有1OO年的日历,具有掉电不丢失性,能够通过按键调整时间.DS1 ...

  2. MSP430G2553 launchpad 口袋板 口袋实验平台 数字电子日历时钟设计 秒表 闹钟 整点报时 万年历 电子时钟

    题10 数字电子日历/时钟设计 设计一个基于MSP430的电子日历和时钟. 基本要求 (1)可通过按键在日历和时间之间切换显示: (2)可由按键调整日期和时间 (3)可整点报时('铆.嘟"声 ...

  3. python数码时钟代码_Python+Pyqt实现简单GUI电子时钟

    本文实例为大家分享了Python+Pyqt实现简单GUI电子时钟的具体代码,供大家参考,具体内容如下 突发奇想想用GUI做一个简单的电子时钟界面,利用pyqt模块也很方便,代码如下: from PyQ ...

  4. esp8266oled做时钟python_ESP8266实战一——带OLED显示屏电子时钟

    ESP8266+Arduino IDE--电子时钟 项目简介 鸽了太久了,今天终于来填坑了,还记得上次记录esp8266入门时我挖的坑吗 忘了就点它.,现在他来了,怎么样?是不是有点东西[偷笑],纯手 ...

  5. 电子时钟单片机c语言程序,51单片机电子时钟C语言程序

    本程序基于ATM89系列单片机的电子时钟C语言程序,能显示月日时分秒,同时还能调节其值!显示方式用六个8段数码管! #include//头文件 #define uchar unsigned char/ ...

  6. C语言制作电子时钟程序(内附代码)

    今天来用C语言制作一款电子时钟程序,相信你们一定能用的上. 效果展示 1.窗口创建   2.基本绘图 3.时间获取 4.代码展示 绘制表盘部分代码: #include <stdio.h> ...

  7. 基于8051单片机实现电子时钟+数字秒表设计

    电子时钟+数字秒表设计 概述 设计任务的基本要求 整体方案 电路设计原理 软件设计 元件清单 项目下载地址 概述 电子时钟是一种利用数字电路来显示秒.分.时的计时装置,与传统的机械钟相比,它具有走时准 ...

  8. 微型计算机系统电子时钟程序设计,基于单片机的电子时钟设计 普通单片机电子时钟的设计的分析...

    摘要:随着电子科技的飞速发展,尤其是超大规模集成电路的出现,给我国的经济带来了实质性的改变.其中,对于单片机的使用已经在很多领域都有出现,比如说在工业自动化控制房间.在智能仪器仪表方面以及各种家用电器 ...

  9. Arduino提高篇23—OLED电子时钟

    在前篇文章中,我们通过库函数驱动DS1302获取到时间数据并且通过串口输出,而串口只是方便调试,要制作电子时钟,我们需要使用显示模块,本篇结合OLED对时间数据进行展示. 1. 实验材料 Uno R3 ...

  10. [SugerTangYL] 简易电子时钟Verilog设计

    目录 前言 一.简易电子时钟的功能要求 二.设计思路&整体框架 三.完整代码 四.仿真 总结 前言 来分享第一个案例了!简易电子时钟的Verilog设计,电子时钟应该算是走嵌入式和FPGA开发 ...

最新文章

  1. Lua和C语言的交互——C API
  2. 泛海精灵的用户分析:补充【Song Xie】
  3. neural network ppt for support vector machine
  4. ConfigurationManager.AppSettings[] ConfigurationManager智能显示不出来
  5. openglshader实现虚拟场景_虚拟演播室设计原则
  6. Hadoop YARN配置参数剖析—RM与NM相关参数
  7. YOLO: Real-Time Object Detection 遇到的问题
  8. 2022年ADB 命令知多少?一文2000字详细 ADB 命令大全来啦
  9. java 代码生成器 generator
  10. [Spring Boot 系列] 集成maven和Spring boot的profile 专题
  11. 刷新ListView刷新时的闪烁问题
  12. 能当「公务员」、服务员,商用服务机器人今年为啥这么火?
  13. docx4j操作word文档之替换模板数据
  14. 窗口大小不规范,教你怎么写默认窗口
  15. rpm 打包及其命令
  16. 影子卫士汉化语言包 res.ini
  17. 计算机共享输入命令是什么意思,笔记本电脑共享WiFi命令怎么使用
  18. openwrt配置doh
  19. Umeng统计-上报事件
  20. 我国计算机最早应用于会计工作的单位是,ERP精品课程第一章

热门文章

  1. FlexRay汽车通信总线介绍及测试环境
  2. 傅里叶变换解析-来龙去脉全解析
  3. 《TCP/IP卷》读书笔记
  4. tarena学习EJB笔记
  5. Halcon 关于角度问题的总结
  6. 出国留学考试指导大全:托福85分是个坎儿
  7. 2022第七届少儿模特明星盛典 小主持人江姿莹 T台风采展示
  8. ros串口/摄像头 别名及查看绑定
  9. 测评您的大数据薪资水平
  10. 写个人简历的时候字体不完整?一个小技巧搞定!