Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <graphics.h>
- #include <iostream>
- #include <stdlib.h>
- #include <conio.h>
- #include <math.h>
- int gdriver,gmode,ls,L;
- using namespace std;
- void init()
- {
- gdriver = DETECT;
- initgraph(&gdriver,&gmode,"E:\\BORLANDC\\BGI");
- if (graphresult())
- {
- cout<<"Tentativa nereusita.";
- cout<<"Apasa o tasta pentru a inchide...";
- getch();
- exit(1);
- }
- }
- void rotplan(int xc, int yc, int x1, int y1, int &x, int &y, float unghi)
- {
- x=ceil(xc+(x1-xc)*cos(unghi)-(y1-yc)*sin(unghi));
- y=ceil(yc+(x1-xc)*sin(unghi)+(y1-yc)*cos(unghi));
- }
- void desenez(int x1,int y1,int x2,int y2,int n,int ls)
- {
- int x,y;
- if (n<=ls)
- {
- setcolor(YELLOW);
- moveto(x1,y1);
- lineto(x2,y2);
- rotplan(x2,y2,div(3*x2-x1,2).quot,div(3*y2-y1,2).quot,x,y,M_PI/4);
- desenez(x2,y2,x,y,n+1,ls);
- rotplan(x2,y2,div(3*x2-x1,2).quot,div(3*y2-y1,2).quot,x,y,-M_PI/4);
- desenez(x2,y2,x,y,n+1,ls);
- }
- }
- main()
- {
- cout<<"ls= "; cin>>ls;
- init();
- setcolor(6);
- desenez(div(getmaxx(),2).quot,getmaxy(),
- div(getmaxx(),2).quot,getmaxy()-250,1,ls);
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement