Advertisement
lawrheyout

Untitled

Dec 13th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <stdafx.h>
  2. #include <cstdio>
  3. #include <iostream>
  4. #include <graphics.h>
  5. #include <conio.h>
  6. #include <math.h>
  7. #define pi M_PI
  8.  
  9. void Draw(double x, double y, double r, double a)
  10. {
  11.     int i;
  12.     double xx[6], yy[6];
  13.  
  14.     for (i = 0; i<6; i++)
  15.     {
  16.         xx[i] = r*cos(a + i*pi * 2 / 5);
  17.         yy[i] = r*sin(a + i*pi * 2 / 5);
  18.     }
  19.     for (i = 0; i<5; i++)
  20.         line(x + xx[i], y + yy[i], x + xx[i + 1], y + yy[i + 1]);
  21. }
  22.  
  23. void ProvRis(double x, double y, double r, double a, int d)
  24. {
  25.     int i;
  26.     double h;
  27.  
  28.     h = 2 * r*cos(pi / 5);
  29.  
  30.     for (i = 0; i<5; i++)
  31.     {
  32.         Draw(x - h*cos(a + i*pi * 2 / 5), y - h*sin(a + i*pi * 2 / 5), r, a + pi);
  33.         if (d > 0)
  34.             ProvRis(x - h*cos(a + i*pi * 2 / 5), y - h*sin(a + i*pi * 2 / 5), r / (2 * cos(pi / 5) + 1), a, d - 1);
  35.     }
  36.     //Draw (x, y, r, a);
  37.     if (d > 0)
  38.         ProvRis(x, y, r / (2 * cos(pi / 5) + 1), a + pi, d - 1);
  39. }
  40.  
  41. int main()
  42. {
  43.     int gm, gd = DETECT;
  44.  
  45.     initgraph(&gd, &gm, "egavga.bgi");
  46.     ProvRis(320, 260, 95, pi / 2, 3);
  47.     getch();
  48.     closegraph();
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement