-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLOCK.CPP
149 lines (82 loc) · 1.77 KB
/
CLOCK.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
#define arg_sec M_PI/30
#define arg_hour M_PI/6
#define arg_min M_PI/360
void main()
{
int gd=DETECT,gm,sec=0,hour,min,x1=0,y1=0,x2=0,y2=0,x3=0,y3=0;
char *k[13]={"1","2","3","4","5","6","7","8","9","10","11","12"};
struct time t;
initgraph(&gd,&gm,"C:/TURBOC3/bgi");
setcolor(YELLOW);
circle(300,200,200);
circle(300,200,180);
setfillstyle(1,CYAN);
floodfill(300,390,YELLOW);
settextstyle(DEFAULT_FONT,0,2);
int a,b;
for(int i=1;i<=13;i++)
{
a=160*cos(arg_hour*i-M_PI_2);
b=160*sin(arg_hour*i-M_PI_2);
outtextxy(a+300,b+200,k[i-1]);
}
int dig_sec;
char Time_Dig[14];
while(!kbhit())
{
settextstyle(7,0,4);
setcolor(GREEN);
outtextxy(255,110,"SWATI");
setcolor(BLUE);
outtextxy(255,80,"MUDIT");
settextstyle(7,0,1);
setcolor(BLACK);
line(300,200,x1+300,y1+200);
line(300,200,x2+300,y2+200);
line(300,200,x3+300,y3+200);
gettime(&t);
if(sec!=t.ti_sec)
{
sound(5000);
delay(1);
nosound();
}
hour=t.ti_hour;
sec=t.ti_sec;
min=t.ti_min;
Time_Dig[0]=hour/10+48;
Time_Dig[1]=hour%10+48;
Time_Dig[2]=':';
Time_Dig[3]=min/10+48;
Time_Dig[4]=min%10+48;
Time_Dig[5]=':';
Time_Dig[6]=sec/10+48;
Time_Dig[7]=sec%10+48;
Time_Dig[8]='\0';
outtextxy(270,250," ");
x1=150*cos(arg_sec*sec-M_PI_2)*0.98;
y1=150*sin(arg_sec*sec-M_PI_2)*0.98;
x2=150*cos(arg_sec*min-M_PI_2)*0.9;
y2=150*sin(arg_sec*min-M_PI_2)*0.9;
if(hour>12) hour-=12;
x3=150*cos(arg_hour*hour-M_PI_2+arg_min*min)*0.6;
y3=150*sin(arg_hour*hour-M_PI_2+arg_min*min)*0.6;
setcolor(YELLOW);
line(300,200,x1+300,y1+200);
setcolor(CYAN);
line(300,200,x2+300,y2+200);
setcolor(WHITE);
line(300,200,x3+300,y3+200);
setcolor(YELLOW);
outtextxy(270,250,Time_Dig);
delay(50);
}
getch();
closegraph();
restorecrtmode();
}