⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rotate.c

📁 VC各工程的源码集合
💻 C
字号:
/*    This is a program that display a simple clock.
      The exe file may work properly when it is loaded to BGI folder
      No side effects
      Please rate this code
      Email address is prinu_2001@hotmail.com
*/

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

    int gdriver = DETECT, gmode, errorcode;
    struct  time t;
    int r=155,r1=125,r2=150,h=300,k=220;
    int sec_count=0,min_count=0;
    double hr_a,min_a,sec_a;
    int x,y;

clock_value()
{
settextstyle(1, HORIZ_DIR, 3);
outtextxy(480,214,"3");
outtextxy(290,397,"6");
outtextxy(111,215,"9");
outtextxy(285, 38,"12");
settextstyle(5, HORIZ_DIR, 1);
outtextxy(386, 63,"1");
outtextxy(450,126,"2");
outtextxy(450,305,"4");
outtextxy(386,368,"5");
outtextxy(202,368,"7");
outtextxy(138,305,"8");
settextstyle(2, HORIZ_DIR, 6);
outtextxy(138,126,"10");
outtextxy(202, 63,"11");

return 0;
}

get_sec()
{
gettime(&t);

#include "secs.h"
#include "min.h"
#include "hour.h"
#include "alarm.h"                  /* alarm set */
     setcolor(9);                   /*  minute hand */
     x=h+ r2*cos(min_a);
     y=k+ r2*sin(min_a);
     line(h, k, x, y);

     setcolor(8);                   /*  hour hand */
     x=h+ r1*cos(hr_a);
     y=k+ r1*sin(hr_a);
     line(h, k, x, y);

return 0;
}

analog_clock()
{
if(!kbhit())
 {
    while(sec_a<=560)
    {
     #include "alarm.h"                  /* alarm set */
     setcolor(4);                    /*  rewrite seconds hand */
     x=h+ r*cos(sec_a);
     y=k+ r*sin(sec_a);
     delay(600);
     line(h, k, x, y);

     x=h+ r*cos(sec_a);
     y=k+ r*sin(sec_a);              /*  clear seconds hand */
     delay(600);
     setcolor(0);
     line(h, k, x, y);
     if(kbhit())
     break;
     sec_a=sec_a+0.1;
     if(sec_count==59)
     {
       min_move();
       sec_count=-3;
     }
     sec_count++;

	       setcolor(9);                   /*  rewrite minute hand */
	       x=h+ r2*cos(min_a);
	       y=k+ r2*sin(min_a);
	       line(h, k, x, y);
	       setcolor(8);                   /*  rewrite hour hand */
	       x=h+ r1*cos(hr_a);
	       y=k+ r1*sin(hr_a);
	       line(h, k, x, y);

}}
return 0;
}

min_move()
{
   setcolor(0);                   /*  clear minute hand */
   x=h+ r2*cos(min_a);
   y=k+ r2*sin(min_a);
   line(h, k, x, y);

   min_a=min_a+0.1;

   setcolor(9);                   /*  rewrite minute hand */
   x=h+ r2*cos(min_a);
   y=k+ r2*sin(min_a);
   line(h, k, x, y);
   if(min_count==11)
   {
     hour_move();
     min_count=-2;
   }
   min_count++;

return 0;
}

hour_move()
{
   setcolor(0);                   /*  clear hour hand */
   x=h+ r1*cos(hr_a);
   y=k+ r1*sin(hr_a);
   line(h, k, x, y);

   hr_a=hr_a+0.1;

   setcolor(8);                   /*  rewrite hour hand */
   x=h+ r1*cos(hr_a);
   y=k+ r1*sin(hr_a);
   line(h, k, x, y);

return 0;
}

int main(void)
{
   initgraph(&gdriver, &gmode, "");
   setcolor(6);
   setbkcolor(YELLOW);
   clock_value();
   get_sec();
   analog_clock();
   closegraph();
   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -