| Back to logs list
71665 2009 年 09 月 26 日 02:54 Reading (loading. ..) Comments (0) Category: Learning Power
TC run, because inside the graphics library is a TC, VC + + has his own graphics library also,
la gears!
/********************************************** **********************
program name: the art of using C language description of the function clock program
: run the program After, there will be an activity used by the clock interface
function: setwritemode (1); gettime (t);
write date: 2006/X/X
modified date: 2008 / 4/8/20: 31
Note: To modify the Options> linker> Graphics library - to On
/************** ************************************************** ***/
# include
# include
# include
# 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,
la gear sale, b, c); line (300,
la gear sneakers,240, x, y );
/******************* fun --- init ******************** *****/
void init ()
{int i, l, x1, x2, y1, y2;
setbkcolor (1);
circle (300,240,200);
circle (300,240,205);
circle (300,240,5);
for (i = 0; i <60; i + +)
{if (i% 5 == 0) l = 15;
else l = 5;
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;
line (x1, y1, x2, y2);
;}
}
/ *** struct time {h = t [0]. ti_hour; m = t [0]. ti_min; s = t [0]. ti_sec ;};*** ***/
/*********** main *************************** ***********************/
main ()
{int x, y;
int gdriver = DETECT, gmode;
unsigned char h, m, s;
struct time t [1];
initgraph (& gdriver, & gmode, );
setwritemode (1);
gettime (t);
h = t [0]. ti_hour;
m = t [0]. ti_min;
s = t [0 ]. ti_sec;
setcolor (7); setlinestyle (0,0,3); d (130, h, 30);
setcolor (14); setlinestyle (0,0,2); d (165 , m, 6);
setcolor (4); setlinestyle (0,
la lights,0,1); d (190, s, 6);
/********* while **** ************************************************** /
while (! kbhit ())
{while (t [0]. ti_sec == s) gettime (t);
; sound (400); delay (70); nosound ();
setcolor ( 4); d (190, s, 6);
s = t [0]. ti_sec; d ( 190,
la gears sneakers, s,
la gear footwear, 6);
if (t [0]. ti_min! = m)
{setcolor (14); d ( 170, m, 4);
m = t [0]. ti_min; d (170, m, 4);
}
if (t [0]. ti_hour! = h)
{setcolor (7); d (150, h, 30);
h = t [0]. ti_hour; d (150 , h, 30);
sound (1000); delay (140);
sound (2000); delay (240);
nosound ();
}
}
getch ();
closegraph ();
}
/****** ************************************ END ************* ****************/