Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdafx.h>
- #include <cstdio>
- #include <iostream>
- #include <graphics.h>
- #include <conio.h>
- #include <math.h>
- #define pi M_PI
- void Draw(double x, double y, double r, double a)
- {
- int i;
- double xx[6], yy[6];
- for (i = 0; i<6; i++)
- {
- xx[i] = r*cos(a + i*pi * 2 / 5);
- yy[i] = r*sin(a + i*pi * 2 / 5);
- }
- for (i = 0; i<5; i++)
- line(x + xx[i], y + yy[i], x + xx[i + 1], y + yy[i + 1]);
- }
- void ProvRis(double x, double y, double r, double a, int d)
- {
- int i;
- double h;
- h = 2 * r*cos(pi / 5);
- for (i = 0; i<5; i++)
- {
- Draw(x - h*cos(a + i*pi * 2 / 5), y - h*sin(a + i*pi * 2 / 5), r, a + pi);
- if (d > 0)
- 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);
- }
- //Draw (x, y, r, a);
- if (d > 0)
- ProvRis(x, y, r / (2 * cos(pi / 5) + 1), a + pi, d - 1);
- }
- int main()
- {
- int gm, gd = DETECT;
- initgraph(&gd, &gm, "egavga.bgi");
- ProvRis(320, 260, 95, pi / 2, 3);
- getch();
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement