Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<graphics.h>
- #define angle (30*3.145)/180
- #include<math.h>
- r(int l,double a,int x,int y)
- {
- if(l!=0)
- {
- double a1=a+angle;
- double a2=a-angle;
- int x1=x+l*cos(a1);
- int y1=y-l*sin(a1);
- line(x,y,x1,y1);
- r(l/2,a1,x1,y1);
- x1=x+l*cos(a2);
- y1=y-l*sin(a2);
- line(x,y,x1,y1);
- r(l/2,a2,x1,y1);
- }
- }
- void fractal()
- {
- printf("fractal tree");
- line(400,600,400,400);
- r(150,(90*3.14)/180,400,400);
- getch();
- }
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"c:\\tc1\\tc\\tc\\bgi");
- fractal();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment