c语言编写钟表的问题

来源:百度知道 编辑:UC知道 时间:2024/09/21 08:01:46
程序的开头是这样定义的,但是我不知什么意思。希望高手能够不吝赐教。不明白的语句后面标注为“--?”:
#include <graphics.h>
#include <math.h>
#include <dos.h>
#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) -- ?

希望明白此语句的朋友能够给出一个详细的解答,以使我能够豁然开朗。在此不胜感激了!
特别是这句:
#define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y)

什么意思?谢了

#include<graphics.h>
#include<math.h>
#include<dos.h>

#define PI 3.1415926
#define x0 320 /*定义钟表中心坐标*/
#define y0 240

void DrawClock(int x,int y,int color) /*画表盘*/
{ int r=150; /*表盘的半径*/
float th;
setcolor(color);
circle(x,y,r);
circle(x,y,2);
}

void DrawHand(int x,int y,float th,int l,int color)
{
int x1,y1;
x1=x l*sin(th);
y1=y-l*cos(th);
setcolor(color);
line(x,y,x1,y1);
}

void main()
{int gdriver=DETECT,gmode;
struct time curtime;
float th_hour,th_min,th_sec;
initgraph(&gdriver,&gmode,"");

setbkcolor(0);

while(! kbhit())
{
DrawClock(x0,y0,14);
gettime(&curtime); /*得到当前系统时间*/

gotoxy(35,20); /*定位输出位置*/
if((float)curtime.ti_hour<=12) /*午前的处理*/
{printf("AM ");
if((float)curtime.ti_hour<10) printf("0"); /*十点之前在小时数前加零*/