#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<br/>setbkcolor(1)<br/>circle(300,240,200)<br/>circle(300,240,205)<br/>circle(300,240,5)<br/>for(i=0i<60i++)<br/>{if(i%5==0) l=15<br/>else l=5<br/>x1=200*cos(i*6*pi/180)+300<br/> y1=200*sin(i*6*pi/180)+240<br/> x2=(200-l)*cos(i*6*pi/180)+300<br/> y2=(200-l)*sin(i*6*pi/180)+240<br/> line(x1,y1,x2,y2)<br/> }
}
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)<br/> gettime(t)<br/> sound(400)<br/> delay(70)<br/> sound(200)<br/> delay(30)<br/> nosound()<br/> setcolor(4)<br/> d(190,s,6)<br/> s=t[0].ti_sec<br/> d(190,s,6)<br/> if (t[0].ti_min!=m)<br/> {<br/> setcolor(14)<br/> d(170,m,6)<br/> m=t[0].ti_min<br/> d(170,m,6)<br/> }
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()
}
代码如下:
Dim a As Integer '这个是秒
Dim b As Integer 'z这个是分
Dim c As Integer '这个是小时
Private Sub Command1_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Command1.Caption = "停止"
Else
Timer1.Enabled = False
Command1.Caption = "开始"
End If
End Sub
Private Sub Command2_Click()
a = 0
b = 0
c = 0
End Sub
Private Sub Timer1_Timer()
a = a + 1
If a = 60 Then
b = b + 1
a = 0
End If
If b = 60 Then
c = c + 1
b = 0
End If '以上纯粹是计时
D = b * 1
Text1.Text = D '这个是计算钱的
Label1.Caption = c &":" &b &":" &a '这个是用来显示时间的
If c = 1 Then '判断是否到1小时了
Timer1.Enabled = False '停止计时器
Shape1.BackColor = RGB(255, 0, 0) '绿球变红球
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)