一个有趣的时钟程序,大家给点意见

yongzhi130 2005-05-07 06:56:27
#include <graphics.h>
#include <math.h>
#include <dos.h>
#define pi 3.1415926
#define x(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300;
#define y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240;
#define d(a,b,c) x(a,b,c);y(a,b,c);line(300,240,x,y)

void init()
{
int i,l,x1,x2,y1,y2;
setbkcolor(1);
circle(300,240,200);
circle(300,240,205);
circle(300,240,5);
for(i=0;i<60;i++)
{
if(i%5==0) l=15;
else l=5;
x1=200*cos(i*6*pi/180)+300;
y1=200*sin(i*6*pi/180)+240;
x2=(200-l)*cos(i*6*pi/180)+300;
y2=(200-l)*sin(i*6*pi/180)+240;
line(x1,y1,x2,y2);
}
}

main()
{
int x,y;
int gd=VGA,gm=VGAHI;
unsigned char h,m,s;
struct time t[1];
initgraph(&gd,&gm,"");
init();
setwritemode(1);
gettime(t);
h=t[0].ti_hour;
m=t[0].ti_min;
s=t[0].ti_sec;
setcolor(7);
d(150,h,30);
setcolor(14);
d(170,m,6);
setcolor(4);
d(190,s,6);
while(!kbhit())
{
while(t[0].ti_sec==s)
gettime(t);
sound(400);
delay(70);
sound(200);
delay(30);
nosound();
setcolor(4);
d(190,s,6);
s=t[0].ti_sec;
d(190,s,6);
if(t[0].ti_min!=m)
{
setcolor(14);
d(170,m,6);
m=t[0].ti_min;
d(170,m,6);
}
if(t[0].ti_hour!=h)
{
setcolor(7);
d(150,h,30);
sound(1000);
delay(240);
nosound();
delay(140);
sound(2000);
delay(240);
nosound();
}
}
getch();
closegraph();
}
...全文
281 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
ltc_mouse 2005-05-24
  • 打赏
  • 举报
回复
呵呵,不错,音画都有了,TC下的多媒体~
楼主可以再添加一些功能~
yongzhi130 2005-05-24
  • 打赏
  • 举报
回复
这个程序在turbo c2.0下编译通过的
dzw2004 2005-05-09
  • 打赏
  • 举报
回复
<graphics.h>只在c的标准库中,c++中没有,为什么不放在tc下编?
djfsos 2005-05-09
  • 打赏
  • 举报
回复
是bc做的吗,在option下的linker下的libraries下有一个graphics library选项,选上看看
cbcbear 2005-05-09
  • 打赏
  • 举报
回复
graphics.h是TC下的库。VC++中是没有的。
zhousqy 2005-05-08
  • 打赏
  • 举报
回复
TC下有这个库
lbing7 2005-05-08
  • 打赏
  • 举报
回复
同意


TC下面是有的!
zhangqiushui 2005-05-08
  • 打赏
  • 举报
回复
在加多一点功能就好了
  • 打赏
  • 举报
回复
用TC2或BC3
flying_dancing 2005-05-08
  • 打赏
  • 举报
回复
BLOG里面也有一个 我看得正郁闷
呵呵 ....
我看你这个小先看看先
#include <graphics.h>这个C++没有 可惜
note_code 2005-05-08
  • 打赏
  • 举报
回复
可惜不能在VC下编译.vc++6连graphics.h这个头文件都没有.晕!
heonmerry 2005-05-08
  • 打赏
  • 举报
回复
UP楼上的,有点问题。#include <graphics.h>这个头文件没有,我是刚学C++的,看不懂,有一个错误,我也不知道怎么办,反正有点问题。。。
zsh6709 2005-05-08
  • 打赏
  • 举报
回复
可惜编译时提示出错了,因为#include <graphics.h>这个头文件没有!!
怎么才能打开呢?
mostideal 2005-05-08
  • 打赏
  • 举报
回复
是不错的。。。
qinxiaolin 2005-05-07
  • 打赏
  • 举报
回复
恩,很不错哦!
oyljerry 2005-05-07
  • 打赏
  • 举报
回复
嗯,加点显示
Flood1984 2005-05-07
  • 打赏
  • 举报
回复
看过了,
不错,自动取得系统时间并显示出来,
呵呵~
只是为什么不打印几个数字上去呢?

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧