C语言钟表设计(国外英文资料)
C语言钟表设计(国外英文资料)
/ * electronic clock source code * /
# include < graphics. H >
# include < stdio, h >
H # include < math.h >
# include < DOS. H >
# include < string. H >
# include < conio. H >
# define PI 3.1415926 / * defines constant * /
# define UP 0x4800 / * UP the arrow key: modify the time * /
# define DOWN 0x5000 / * DOWN the key: modify the time * /
# define ESC 0x11b / * ESC key: exit system * /
# define TAB 0xf09 / * TAB key: move the cursor * /
/ * function declaration * /
Int keyhandle (int, int); / * keystroke, and call the relevant functions to handle * /
Int timeupchange (int); / * to move the buttons * /
Int timedownchange (int); / * handle the lower button * /
Int digithour (double); / * convert the double hour number to int * /
Int digitmin (double); / * convert the double minutes to int * /
Int digitsec (double); / * convert the double seconds to int * /
Void digit clock (int, int, int); / * to display the clock or minutes or seconds in a specified location
Void drawcursor (int); / * draw a cursor * /
Void clearcursor (int); / * eliminate the previous cursor * /
Void clockhandle (); / * clock processing * /
Double h, m, s; / * global variables: hours, minutes, seconds
Double x, x1, x2, y, y1, y2; / * global variable: the value of the seat is * /
Struct time t [1]; / * defines an array of time structure types * /
The main ()
{
Int driver, mode = 0, I, j;
Driver = DETECT; / * automatic detection display device * /
The initgraph. / * initialize the graphical system * /
Errorcode = graphresult () / * will have a good prompt interface when the exception occurs when an exception occurs when the graph is initialized
An error occurs when the errorcode (= grOk) / * graph is initialized
{
Printf (" Graphics error: % s/n ", grapherrormsg (errorcode));
Printf (" Press any key to halt: ");
Getch ();
The exit (1); / * return with error code * /
}
,0,3 setlinestyle (0); / * set the current line width and type: set the four point wide line
Setbkcolor (0); / * set