The alarm clock program implemented in C language

Source: Internet
Author: User
Tags cos current time sin

#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <dos.h>
#include <stdio.h>
void Main ()
{
int gd=detect,gm;
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
struct time t;
Char n[12][3]={"3", "2", "1", "12", "11", "10", "9", "8", "7", "6", "5", "4"};
Initgraph (&AMP;GD,&AMP;GM, "G:\TC\BGI");//Graphics drive path, replace according to your system.
Circle (x,y,210);
SetColor (4);
Settextstyle (4,0,5);
for (i=0;i<12;i++)
{
if (i!=3)
Outtextxy (x+ (r-14) *cos (m_pi/6*i) -10,y-r-14 (*sin) m_pi/6*i]);
Else
Outtextxy (x+ (r-14) *cos (m_pi/6*i) -20,y-r-14 (*sin) m_pi/6*i]);
}
GetTime (&t);
printf ("The current time is:%2d:%02d:%02d.%0 2d\n ", T.ti_hour, T.ti_min,
T.ti_sec, T.ti_hund);
while (!kbhit ())
{
SetColor (5);
Setfillstyle (1,5);
Circle (x,y,10);
FloodFill (x,y,5);
GetTime (&t);
if (t.ti_min!=m)
{
SetColor (0);
Line (x,y,x+ (r-60) *cos (thetamin* (m_pi/180)), Y (r-60) *sin (thetamin* (m_pi/180
)));
Circle (x+ (r-80) *cos (thetamin* (m_pi/180)), Y (r-80) *sin (thetamin* (m_pi/180))
, 10);
Line (x,y,x+ (r-110) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-110) *sin (m_pi/6*h
-((M/2) * (m_pi/180)));
Circle (x+ (r-130) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-130) *sin (m_pi/6*h-(
(M/2) * (m_pi/180)), 10);
}
if (t.ti_hour>12)
t.ti_hour=t.ti_hour-12;
if (t.ti_hour<4)
H=abs (t.ti_hour-3);
Else
H=15-t.ti_hour;
M=t.ti_min;
if (t.ti_min<=15)
Thetamin= (15-t.ti_min) *6;
Else
thetamin=450-t.ti_min*6;
if (t.ti_sec<=15)
Thetasec= (15-t.ti_sec) *6;
Else
thetasec=450-t.ti_sec*6;
SetColor (4);
Line (x,y,x+ (r-110) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-110) *sin (m_pi/6*h
-((M/2) * (m_pi/180)));
Circle (x+ (r-130) *cos (m_pi/6*h-(M/2) * (m_pi/180)), Y (r-130) *sin (m_pi/6*h-(
(M/2) * (m_pi/180)), 10);
Line (x,y,x+ (r-60) *cos (thetamin* (m_pi/180)), Y (r-60) *sin (thetamin* (m_pi/180
)));
Circle (x+ (r-80) *cos (thetamin* (m_pi/180)), Y (r-80) *sin (thetamin* (m_pi/180))
, 10);
SetColor (15);
Line (x,y,x+ (r-70) *cos (thetasec* (m_pi/180)), Y (r-70) *sin (thetasec* (m_pi/180
)));
Delay (1000);
SetColor (0);
Line (x,y,x+ (r-70) *cos (thetasec* (m_pi/180)), Y (r-70) *sin (thetasec* (m_pi/180
)));
}
}

The program has been compiled in Turbo c++3.0.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.