急求用c++语言编写时钟表的程序.

来源:百度知道 编辑:UC知道 时间:2024/07/08 07:46:18
必须用c++语言编写

#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(&