| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 185 人关注过本帖
标题:求高手解释,教教怎么改?
取消只看楼主 加入收藏
lxr19931009
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-7-6
收藏
 问题点数:0 回复次数:0 
求高手解释,教教怎么改?
小弟做了一个C语言时钟的图形界面的程序如下:
在运行时发现走到整点时,时针自动退回1小时
如“8:59到9:00时时针退回8:00”求高手予以
矫正,急用谢谢!!!
#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)
#define c(a,b,c,d) X(a,b,c);Y(a,b,c);circle(x,y,d)
void init()
{
int i,l,x1,y1,x2,y2,x3,y3;
setbkcolor(0);
setcolor(10);
circle(300,240,230);
setcolor(6);
circle(300,240,220);
setcolor(5);
circle(300,240,210);
setcolor(10);
circle(300,240,7);
for(i=0;i<60;i++)
{
if(i%5==0)
l=7;
else
l=4;
x1=220*sin(i*6*pi/180)+300;
y1=220*cos(i*6*pi/180)+240;
x2=115*sin(i*6*pi/180)+300;
y2=115*cos(i*6*pi/180)+240;
x3=(115-l)*sin(i*6*pi/180)+300;
y3=(115-l)*cos(i*6*pi/180)+240;
setcolor(6);
circle(300,240,120);
line(x2,y2,x3,y3);
setcolor(2);
circle(x1,y1,l);
}
}
main()
{
int x,y,i,k=1;
int gdriver=9,gmode=2;
unsigned char h,m,s;
int o,p,q;
float n;
struct time t[1];
struct date d[1];
initgraph(&gdriver,&gmode,"c:\\tc");
initgraph(&gdriver,&gmode,"c:\\tc");
for(i=0;i<=6;i++)
{
settextstyle(TRIPLEX_FONT,HORIZ_DIR,i);
cleardevice();
settextjustify(1,1);
outtextxy(300,40,"twelve") ;
outtextxy(300,440,"six");
outtextxy(110,239,"nine");
outtextxy(485,239,"three");
outtextxy(395,73,"one");
outtextxy(210,73,"eleven");
outtextxy(460,140,"two");
outtextxy(460,340,"four");
outtextxy(395,410,"five");
outtextxy(210,410,"seven");
outtextxy(140,140,"ten");
outtextxy(140,335,"eight");
}
init();
setwritemode(1);
if(k!=0)
{
getdate(d);
o=d[0].da_year;
p=d[0].da_mon;
q=d[0].da_day;
gettime(t);
h=t[0].ti_hour;
m=t[0].ti_min;
s=t[0].ti_sec;
}
setcolor(7);
n=(float)h+(float)m/60;
d(110,n,30);
c(80,n,30,7);
setcolor(14);
d(170,m,6);
c(130,m,6,10);
setcolor(4);
d(190,s,6);
c(150,s,6,12);
while(!kbhit())
{
while(t[0].ti_sec==s)
gettime(t);
gotoxy(44,18);
printf("\b\b\b\b\b\b\b\b\b");
sound(400);
delay(240);
sound(200);
delay(240);
nosound();
setcolor(4);
d(190,s,6);
c(150,s,6,12);
s=t[0].ti_sec;
d(190,s,6);
s=t[0].ti_sec;
c(150,s,6,12);
if(t[0].ti_min!=m)
{
setcolor(14);
d(170,m,6);
c(130,m,6,10);
m=t[0].ti_min;
d(170,m,6);
c(130,m,6,10);
}
if(t[0].ti_hour!=h)
{
setcolor(7);
d(150,h,30);
c(150,h,30);
h=t[0].ti_hour;
d(150,h,30,8);
c(150,h,30,8);
sound(1000);
delay(240);
nosound();
delay(140);
sound(2000);
delay(240);
nosound();
}
if(s<10)
{ if(m<10)
printf("%u:0%u:0%u",h,m,s);
else
printf("%u:%u:0%u",h,m,s);
}
else
{ if(m<10)
printf("%u:0%u:%u",h,m,s);
else
printf("%u:%u:%u",h,m,s);
}
gotoxy(34,19);
if(p<10) printf("%d.0%d.%d",o,p,q);
else printf("%d.%d.%d",o,p,q);
gotoxy(29,20);
printf("make by Liu Xiangrui");
printf("\b\b\b\b\b\b\b\b\b");
}
getch();
closegraph();
}
搜索更多相关主题的帖子: C语言 
2011-07-06 21:01
快速回复:求高手解释,教教怎么改?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017390 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved