C语言钟表.docx

上传人:b****5 文档编号:7568219 上传时间:2023-05-11 格式:DOCX 页数:7 大小:14.88KB
下载 相关 举报
C语言钟表.docx_第1页
第1页 / 共7页
C语言钟表.docx_第2页
第2页 / 共7页
C语言钟表.docx_第3页
第3页 / 共7页
C语言钟表.docx_第4页
第4页 / 共7页
C语言钟表.docx_第5页
第5页 / 共7页
C语言钟表.docx_第6页
第6页 / 共7页
C语言钟表.docx_第7页
第7页 / 共7页
亲,该文档总共7页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

C语言钟表.docx

《C语言钟表.docx》由会员分享,可在线阅读,更多相关《C语言钟表.docx(7页珍藏版)》请在冰点文库上搜索。

C语言钟表.docx

C语言钟表

C语言钟表

——可改时间(非系统时间)#include

#include

#include

#include

#definepi3.197169399

#defineX(a,b,c)x=a*cos(b*c*pi/180-pi/2)+300;

#defineY(a,b,c)y=a*sin(b*c*pi/180-pi/2)+240;

#defined(a,b,c)X(a,b,c);Y(a,b,c);line(300,240,x,y)

voidinit()

{

inti,l,x1,x2,x3,y1,y2,y3,x4,y4,bt;

setbkcolor

(1);

circle(300,240,200);

circle(300,240,205);

circle(300,240,5);

circle(300,240,4);

for(i=0;i<60;i++)

{

if(i%5==0)l=15;

elsel=5;

if(l==15)bt=1;

elsebt=0;

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;

x3=bt*(200*cos((i-.4)*6*pi/180)+300);

y3=bt*(200*sin((i-.4)*6*pi/180)+240);

x4=bt*(200*cos((i+.4)*6*pi/180)+300);

y4=bt*(200*sin((i+.4)*6*pi/180)+240);

line(x1,y1,x2,y2);

if(bt==1)line(x2,y2,x3,y3);

if(bt==1)line(x2,y2,x4,y4);

}

}

voidA()

{

intx,y;

intgd=VGA,gm=2;

unsignedcharh,m,s;

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

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

}

voidB(intj,intk,intl)

{

intx,y,gggg;

intgd=VGA,gm=2;

unsignedinth,m,s;

structtimet[1];

structtimeu[1];

initgraph(&gd,&gm,"d:

\\tc");

init();

setwritemode

(1);

gettime(t);

gettime(u);

h=j;

m=k;

s=l;

getchar();

t[0].ti_sec=s;

t[0].ti_min=m;

t[0].ti_hour=h;

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

/*printf("1.t0.timin%d\n",t[0].ti_sec);

printf("1.u0.timin%d\n",u[0].ti_sec);

printf("1.l%d\n",l);*/

gggg=t[0].ti_sec-u[0].ti_sec+l;

if(gggg<0)

{

gggg=gggg+60;

}

t[0].ti_sec=gggg;

t[0].ti_min=t[0].ti_min-u[0].ti_min+k;t[0].ti_hour=t[0].ti_hour-u[0].ti_hour+j;/*printf("2.t0.tihour%d\n",t[0].ti_sec);*/nosound();

delay(70);

nosound();

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

}

main()

{

inta,j,k,l;

charww;

printf("Doyouwanttochangetime?

(Y/N)\n");

do

{

ww=getchar();

}while(ww!

='Y'&&ww!

='N');

if(ww=='N')

{

A();

}

else

{

printf("pleaseinputtimeastheformofAABBCC\n");

scanf("%d%d%d",&j,&k,&l);

B(j,k,l);

}

}

注:

请检查TC2.0(dosbox)是否可画图

程序改自诚挚感谢——

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2