Advertisement
Guest User

clock.cpp

a guest
Jul 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.63 KB | None | 0 0
  1. #include<time.h>
  2. #include<stdlib.h>
  3. #include<stdio.h>
  4. #include<iostream>
  5. #include<graphics.h>
  6. #include<conio.h>
  7. #include<ctime>
  8. #include<cmath>
  9. void digits(int k)
  10. {
  11.     setcolor(15);
  12.     setlinestyle(SOLID_LINE, 1, 1);
  13.     bgiout << "12";
  14.     outstreamxy(300, 5);
  15.     bgiout << "6";
  16.     outstreamxy(300, 435);
  17.     bgiout << "3";
  18.     outstreamxy(510, 230);
  19.     bgiout << "9";
  20.     outstreamxy(80, 230);
  21.     bgiout << "1";
  22.     outstreamxy(400, 40);
  23.     bgiout << "2";
  24.     outstreamxy(480,110);
  25.     bgiout << "4";
  26.     outstreamxy(480, 330);
  27.     bgiout << "5";
  28.     outstreamxy(400, 410);
  29.     bgiout << "7";
  30.     outstreamxy(185, 410);
  31.     bgiout << "11";
  32.     outstreamxy(180, 40);
  33.     bgiout << "8";
  34.     outstreamxy(110, 330);
  35.     bgiout << "10";
  36.     outstreamxy(110, 110);
  37.     //bgiout << "0";
  38.     //outstreamxy(300,230);
  39.     setcolor(3);
  40.    circle(300,230,5);
  41.    setcolor((k%8)+1);
  42.    circle(300,110,20);
  43.    setcolor((k%8)+3);
  44.    circle(300,350,20);
  45.    setcolor((k%8)+2);
  46.    circle(185,230,20);
  47.    setcolor((k%8)+4);
  48.    circle(415,230,20);
  49. }
  50. void hour(int x,int y,int h,int m)
  51. {
  52.     setcolor(1);
  53.     setlinestyle(SOLID_LINE, 1, 5);
  54.     h=h%12;
  55.     int angle;
  56.     double ang,val=130;
  57.     angle=h*30;
  58.     m=m/2;
  59.     angle+=m;
  60.     angle=angle%359;
  61.     ang=angle;
  62.     ang=(ang*3.14159)/180.0;
  63.     line(x,y,x+val*sin(ang),y-val*cos(ang));
  64. }
  65. void minute(int x,int y,int m)
  66. {
  67.     setcolor(2);
  68.     setlinestyle(SOLID_LINE, 1, 3);
  69.     int angle;
  70.     double ang,val=170;
  71.     angle=m*6;
  72.     angle=angle%359;
  73.     ang=angle;
  74.     ang=(ang*3.14159)/180.0;
  75.     line(x,y,x+val*sin(ang),y-val*cos(ang));
  76. }
  77. void second(int x,int y,int s)
  78. {
  79.     setcolor(4);
  80.     setlinestyle(SOLID_LINE, 1, 1);
  81.     int angle;
  82.     double ang,val=210;
  83.     angle=s*6;
  84.     angle=angle%359;
  85.     ang=angle;
  86.     ang=(ang*3.14159)/180.0;
  87.     line(x,y,x+val*sin(ang),y-val*cos(ang));
  88. }
  89. using namespace std;
  90. int main()
  91. {
  92.    int m=0,gd = DETECT,gm,circle_x,circle_y,radius,sx,sy;
  93.    circle_x=300;
  94.    circle_y=230;
  95.    radius=200;
  96.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  97.    //initwindow(1000, 1000);
  98.    //setbkcolor(11);
  99.    while(!kbhit())
  100.    {
  101.        setcolor((m%3)+1);
  102.    circle(circle_x,circle_y,radius+35);
  103.    setcolor(((m+1)%3)+1);
  104.    circle(circle_x,circle_y,radius+30);
  105.    setcolor(((m+2)%3)+1);
  106.    circle(circle_x,circle_y,radius+40);
  107.    digits(m++);
  108.    time_t now=time(0);
  109.    tm *ltm=localtime(&now);
  110.    hour(circle_x,circle_y,ltm->tm_hour,ltm->tm_min);
  111.    minute(circle_x,circle_y,ltm->tm_min);
  112.    second(circle_x,circle_y,ltm->tm_sec);
  113.    delay(1000);
  114.    cleardevice();
  115.    }
  116.    getch();
  117.    closegraph();
  118.    return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement