c语言时钟声音代码大全,c语言时钟代码

#include

/*

引入graphic.h

*/

#include

/*

引入math.h

*/

#include

/*

引入dos.h

*/

#define

pi

3.1415926

/*定义pi=3.14159*/

#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=2;

unsigned

char

h,m,s;

/*定义*/

struct

time

t[1];

initgraph(&gd,&gm,"d:\tc");

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);

/*C语言中得到时间的函数*/

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);

h=t[0].ti_hour;

d(150,h,30);

sound(1000);

delay(240);

nosound();

delay(140);

sound(2000);

delay(240);

nosound();

}

}

getch();

/*设置空格后退出*/

closegraph();

}

具体的。。就是套用用几个函数算时间。。

不要对这种很长的东西害怕,其实大部分都是在画这个钟~

加油哦~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值