Advertisement
edutedu

ARBORI

Oct 22nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <graphics.h>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <math.h>
  6. int gdriver,gmode,ls,L;
  7.  
  8. using namespace std;
  9.  
  10. void init()
  11. {
  12. gdriver = DETECT;
  13. initgraph(&gdriver,&gmode,"E:\\BORLANDC\\BGI");
  14. if (graphresult())
  15. {
  16. cout<<"Tentativa nereusita.";
  17. cout<<"Apasa o tasta pentru a inchide...";
  18. getch();
  19. exit(1);
  20. }
  21. }
  22. void rotplan(int xc, int yc, int x1, int y1, int &x, int &y, float unghi)
  23. {
  24. x=ceil(xc+(x1-xc)*cos(unghi)-(y1-yc)*sin(unghi));
  25. y=ceil(yc+(x1-xc)*sin(unghi)+(y1-yc)*cos(unghi));
  26. }
  27. void desenez(int x1,int y1,int x2,int y2,int n,int ls)
  28. {
  29. int x,y;
  30. if (n<=ls)
  31. {
  32. setcolor(YELLOW);
  33. moveto(x1,y1);
  34. lineto(x2,y2);
  35. rotplan(x2,y2,div(3*x2-x1,2).quot,div(3*y2-y1,2).quot,x,y,M_PI/4);
  36. desenez(x2,y2,x,y,n+1,ls);
  37. rotplan(x2,y2,div(3*x2-x1,2).quot,div(3*y2-y1,2).quot,x,y,-M_PI/4);
  38. desenez(x2,y2,x,y,n+1,ls);
  39. }
  40. }
  41. main()
  42. {
  43. cout<<"ls= "; cin>>ls;
  44. init();
  45. setcolor(6);
  46. desenez(div(getmaxx(),2).quot,getmaxy(),
  47. div(getmaxx(),2).quot,getmaxy()-250,1,ls);
  48. getch();
  49. closegraph();
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement