C语言 用Devc++编一个图形时钟,要求能在devc++上运行的,简简单单的就可以了。

如题所述

//图形库是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;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-12-27
http://zhidao.baidu.com/link?url=gNnuIzPklUAmN5vT4f1ksRfXlXP77KXCKpTLOBKJlOMQzuuF7W861nfWAf3yCzdVQIrL8cehNys1Gg3X3ZIEitOFvR0mH_3iRcxLfhVDyKe

图形时钟,不知道你这个是要在那些地方使用,是在电脑桌面上使用吗?
如果是,就不是devc++能写出来的了,还要设计界面,外观,本回答被网友采纳
第2个回答  2017-09-22
http://zhidao.baidu.com/link?url=gNnuIzPklUAmN5vT4f1ksRfXlXP77KXCKpTLOBKJlOMQzuuF7W861nfWAf3yCzdVQIrL8cehNys1Gg3X3ZIEitOFvR0mH_3iRcxLfhVDyKe图形时钟,不知道你这个是要在那些地方使用,是在电脑桌面上使用吗?如果是,就不是devc++
相似回答