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