![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/fd039245d688d43ff253ebfd761ed21b0ff43bc2?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
//图形库是EGE,下载后配置一下
#include <iostream>
#include "graphics.h"
#include <math.h>
#include <time.h>
#include <windows.h>
#define x0 210.0
#define y0 210.0
#define r 200.0
POINT pt[60],pt_s[60],pt_m[60],pt_h[60],pt1[60];
using namespace std;
int main()
{
initgraph(420,420);
setfillcolor(0xffccff);
setcolor(0xffccff);
fillellipse(x0,y0,10,10);
int s=45,m,h,n=0;
while(n<60)
{
pt_s[s].x=x0+(int)((r-20)*cos((n-90)*3.1415926/30.0));
pt_s[s].y=y0+(int)((r-20)*sin((n-90)*3.1415926/30.0));
pt_m[s].x=x0+(int)((r-50)*cos((n-90)*3.1415926/30.0));
pt_m[s].y=y0+(int)((r-50)*sin((n-90)*3.1415926/30.0));
pt_h[s].x=x0+(int)((r-80)*cos((n-90)*3.1415926/30.0));
pt_h[s].y=y0+(int)((r-80)*sin((n-90)*3.1415926/30.0));
pt[s].x=x0+(int)(r*cos((n-90)*3.1415926/30.0));
pt[s].y=y0+(int)(r*sin((n-90)*3.1415926/30.0));
fillellipse(pt[s].x,pt[s].y,2,2);
n++;
s++;
if(s>=60)
{
s=0;
}
}
for(int i=0;i<12;i++)
{
fillellipse(pt[i*5].x,pt[i*5].y,5,5);
}
int xs,ys,xm=-1,ym=-1,xh=-1,yh=-1;
while(1)
{
int n,m;
SYSTEMTIME st={0};
GetLocalTime(&st);
setcolor(0xffccff);
line(x0,y0,pt_s[st.wSecond].x,pt_s[st.wSecond].y);
xs=pt_s[st.wSecond].x;
ys=pt_s[st.wSecond].y;
if(pt_m[st.wMinute].x!=xm && pt_m[st.wMinute].y!=ym)
{
setcolor(0);
line(x0,y0,xm,ym);
xm=pt_m[st.wMinute].x;
ym=pt_m[st.wMinute].y;
setcolor(0xffccff);
}
line(x0,y0,pt_m[st.wMinute].x,pt_m[st.wMinute].y);
if(st.wHour>12)
{
n=st.wHour-12;
}
else
{
n=st.wHour;
}
m=(n*60+st.wMinute)/12;
line(x0,y0,pt_h[m].x,pt_h[m].y);
Sleep(1000);
setcolor(0x0);
line(x0,y0,xs,ys);
fillellipse(x0,y0,10,10);
}
closegraph();
return 0;
}