文件名称:C语言编写的电子时钟
文件大小:906B
文件格式:RAR
更新时间:2011-12-21 15:03:23
C语言编写的电子时钟
#include "Conio.h" #include "graphics.h" #include "stdio.h" #include "math.h" #include "dos.h" #include "time.h" #define closegr closegraph #define PI 3.1415926 void initgr(void) { int gd = DETECT, gm = 0; registerbgidriver(EGAVGA_driver); initgraph(&gd, &gm, ""); } int main(void) { struct time tim; int end_x,end_y,i,font_x,font_y,XX_sec,YY_sec,XX_hr,YY_hr,XX_min,YY_min; float sec_radian,min_radian,hr_radian,font_radian; int pan=1; initgr(); while(!bioskey(1)) { gettime(&tim); sec_radian=(float)tim.ti_sec*((2*PI)/60); min_radian=(float)tim.ti_min*((2*PI)/60); hr_radian=(float)tim.ti_hour*((2*PI)/12)+min_radian/12; setbkcolor(BLACK); setcolor(BLUE); circle(320,240,220); circle(320,240,150); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); outtextxy(310,130,"clock"); if(pan==1) { setcolor(RED); } else { setcolor(BLACK); line(320,240,XX_sec,YY_sec); line(320,240,XX_min,YY_min); line(320,240,XX_hr,YY_hr); setcolor(RED); }
【文件预览】:
clock.txt