作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/26 04:39:38
样例:
一、设计题目:(宋体五号加黑)
有滴答声音的全屏模拟时钟.(宋体五号)
二、题目阐述及设计思路:
这是一个有声音的全屏模拟时钟,有时针、分针和秒针.根据题目要求,采用C语言自带的画图函数为主要框架,其中各个运算部分运用C语言的函数和基本算法的知识.其余各部分衔接运用顺序结构,分支结构和循环结构.主要内容确定之后,调用所需函数,根据上述计划编译了这段程序.
三、主要知识点:
  使用文件包含、C语言宏定义、图形界面的使用、系统函数调用函数.
四、程序清单:
#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,b,c);line(300,240,x,y)
void init()
{int i,l,x1,x2,y1,y2;
setbkcolor(1);
circle(300,240,200);
circle(300,240,205);
circle(300,240,5);
略……
五、设计结果说明:
1、设计优点:
2、设计不足:
#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_hour)*60;
line(320,240,end_x,end_y);
}
}
/*画心型钟界面*/
void DrawXin(int x0,int y0,int k)
{
float i,x,y,tx,ty;
for(i=-180.0;i
再问: 大侠,我编译时,在第四行怎么会出错了。能再帮我看看嘛?
再答: 你用的是什么平台编译的?