精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>C/C++>>未整理到对应目录的文章>>钟表---源代码

主题:钟表---源代码
发信人: chen82607(chen82607)
整理人: yangcs(2004-10-14 14:22:35), 站内信件
#define PAI 3.141
#define N 0.809
#include "stdio.h"
#include "graphics.h"
#include "time.h"
#include "math.h"
main()
{
 int nu1=0,nu2=0,nu3=0,x0,y0,x,y,z=0,z2=0,driver,mode;
 int x2,y2,x3,y3,z3=0,z4=0,z5=0,z6=0;
 float a,c,d;
 time_t t;
 struct tm t2;
 driver=CGA;mode=CGAC0;
 initgraph(&driver,&mode,"");
 setcolor(3);
 x0=150;y0=100;
 circle(x0,y0,90);
 setcolor(1);
 circle(x0,y0,110);
 settextstyle(DEFAULT_FONT,HORIZ_DIR,0);
 outtextxy(140,18,"12");
 outtextxy(145,178,"6");
 outtextxy(50,100,"9");
 outtextxy(245,100,"3");
 while(!kbhit())
 {
  setcolor(2);
  t=time(NULL);
  t2=*localtime(&t);
  nu1=t2.tm_sec;nu2=t2.tm_min;nu3=t2.tm_hour;
  a=nu1*PAI*2/60-PAI/2;
  c=nu2*PAI*2/60-PAI/2;
  d=nu3*PAI*2/12-PAI/2;
  x=ceil(x0+75*cos(a));
  y=ceil(y0+75*sin(a)*0.809);
  x2=ceil(x0+60*cos(c));
  y2=ceil(y0+60*sin(c)*0.809);
  x3=ceil(x0+40*cos(d));
  y3=ceil(y0+40*sin(d)*0.809);
  line(x0,y0,x,y);
  line(x0,y0,x2,y2);
  line(x0,y0,x3,y3);
  setcolor(0);
  if(z==x&z2==y) ;
   else {line(x0,y0,z,z2);    z=x;z2=y;}
  if(z3==x2&z4==y2);
   else {line(x0,y0,z3,z4);
   z3=x2;z4=y2;  }
  if(z5==x3&z6==y3);
   else {line(x0,y0,z5,z6);
 z5=x3;z6=y3;}
 }
}


----
 
                      \\\|///
                    \\  - -  //
                     (  @ @  )
┏━━━━━━━━━oOOo-(_)-oOOo━┓
┃网海茫茫,认识你是我的福份;     ┃
┃网语缠绵,那是我们注定的缘份。   ┃
┃                          Oooo   ┃
┗━━━━━━━━━ oooO━-(   )━┛
                     (   )   ) /
                      \ (   (_/
                       \_)

[关闭][返回]