样例:一、设计题目:(宋体五号加黑)有滴答声音的全屏模拟时钟.(宋体五号)二、题目阐述及设计思路:这

发布时间:2021-02-20 03:20:46

样例:一、设计题目:(宋体五号加黑)有滴答声音的全屏模拟时钟.(宋体五号)二、题目阐述及设计思路:这是一个有声音的全屏模拟时钟,有时针、分针和秒针.根据题目要求,采用C语言自带的画图函数为主要框架,其中各个运算部分运用C语言的函数和基本算法的知识.其余各部分衔接运用顺序结构,分支结构和循环结构.主要内容确定之后,调用所需函数,根据上述计划编译了这段程序.三、主要知识点:  使用文件包含、C语言宏定

网友回答

#include stdio.h
#include
math.h#include
dos.h#include
graphics.h#define PI 3.1415926
#define th PI/180
#define a 60
void DrawXin(int x0,int y0,int k) ;
void main()
{ int gr=DETECT,gm;
float th_hour,th_min,th_sec,end_x,end_y;
struct time now;
initgraph(&gr,&gm,c:\\turboc2);
cleardevice();
DrawXin(320,200,90);
while (!kbhit())
{ setcolor(YELLOW);
gettime(&now);
/*printf(%.f,%.f,%.f\t,(float)now.ti_hour,(float)now.ti_min,(float)now.ti_sec);*/
th_sec=( 90-(float)now.ti_sec*6 )*th ;
th_min=(90-( (float)now.ti_min+(float)now.ti_sec/60.0 )*6 )*th;
th_hour=(90-( (float)now.ti_hour+(float)now.ti_min/60.0+(float)now.ti_sec/3600.0)*12)*th; /* printf(hour:%.f,min:%.f,sec:%.f\n,th_hour,th_min,th_sec);*/ /*画秒针*/ end_x=320+cos(th_sec)*120; end_y=240-sin(th_sec)*120; line(320,240,end_x,end_y); /*画分针*/ end_x=320+cos(th_min)*90; end_y=240-sin(th_min)*90; line(320,240,end_x,end_y); /*画时针*/ end_x=320+cos(th_hour)*60; end_y=240-sin(th_hour)*60; line(320,240,end_x,end_y); sleep(1); /*隐藏时钟*/ setcolor(RED); end_x=320+cos(th_sec)*120; end_y=240-sin(th_sec)*120; line(320,240,end_x,end_y); end_x=320+cos(th_min)*90; end_y=240-sin(th_min)*90; line(320,240,end_x,end_y); end_x=320+cos(th_hour)*60; end_y=240-sin(th
以上问题属网友观点,不代表本站立场,仅供参考!