Advertisement
yoyoboyss

Untitled

Jun 13th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <graphics.h>
  3. #include <winbgim.h>
  4.  
  5. using namespace std;
  6.  
  7. const int MMAX = 500;
  8. const int LMAX = 800;
  9. const int HMAX = 600;
  10. const int NMAX = 100;
  11.  
  12. int N, R = 300, cnt;
  13. int x_1, y_1, x_2, y_2;
  14. int ans[MMAX][4];
  15. char s[NMAX];
  16.  
  17. int drawTriangleV(int, int, int);
  18.  
  19. int drawTriangleA(int edgeLenght, int x, int y){
  20. int ok = 0;
  21. if(s[cnt + 1] == '(')
  22. ok = 1;
  23.  
  24. line(x, y - 2 * edgeLenght * 1.72 / 6, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  25. if(ok){
  26. cnt += 2;
  27. if(s[cnt + 1] == ')')
  28. ok = 0;
  29. if(s[cnt] != '#'){
  30. if(s[cnt] == 'A')
  31. drawTriangleA(edgeLenght / 2, x, y - 2 * edgeLenght * 1.72 / 6);
  32. else if(s[cnt] == 'V')
  33. drawTriangleV(edgeLenght / 2, x, y - 2 * edgeLenght * 1.72 / 6);
  34. }
  35. }
  36.  
  37. line(x - edgeLenght / 2, y + edgeLenght * 1.72 / 6, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  38. if(ok){
  39. cnt += 2;
  40. if(s[cnt + 1] == ')')
  41. ok = 0;
  42. if(s[cnt] != '#'){
  43. if(s[cnt] == 'A')
  44. drawTriangleA(edgeLenght / 2, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  45. else if(s[cnt] == 'V')
  46. drawTriangleV(edgeLenght / 2, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  47. }
  48. }
  49.  
  50. line(x, y - 2 * edgeLenght * 1.72 / 6, x - edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  51. if(ok){
  52. cnt += 2;
  53. if(s[cnt + 1] == ')')
  54. ok = 0;
  55. if(s[cnt] != '#'){
  56. if(s[cnt] == 'A')
  57. drawTriangleA(edgeLenght / 2, x - edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  58. else if(s[cnt] == 'V')
  59. drawTriangleV(edgeLenght / 2, x - edgeLenght / 2, y + edgeLenght * 1.72 / 6);
  60. }
  61. }
  62. }
  63.  
  64. int drawTriangleV(int edgeLenght, int x, int y){
  65. int ok = 0;
  66. if(s[cnt + 1] == '(')
  67. ok = 1;
  68.  
  69. line(x + edgeLenght / 2, y - edgeLenght * 1.72 / 6, x, y + 2 * edgeLenght * 1.72 / 6);
  70. if(ok){
  71. cnt += 2;
  72. if(s[cnt + 1] == ')')
  73. ok = 0;
  74. if(s[cnt] != '#'){
  75. if(s[cnt] == 'A')
  76. drawTriangleA(edgeLenght / 2, x + edgeLenght / 2, y - edgeLenght * 1.72 / 6);
  77. else if(s[cnt] == 'V')
  78. drawTriangleV(edgeLenght / 2, x + edgeLenght / 2, y - edgeLenght * 1.72 / 6);
  79. }
  80. }
  81.  
  82. line(x - edgeLenght / 2, y - edgeLenght * 1.72 / 6, x, y + 2 * edgeLenght * 1.72 / 6);
  83. if(ok){
  84. cnt += 2;
  85. if(s[cnt + 1] == ')')
  86. ok = 0;
  87. if(s[cnt] != '#'){
  88. if(s[cnt] == 'A')
  89. drawTriangleA(edgeLenght / 2, x, y + 2 * edgeLenght * 1.72 / 6);
  90. else if(s[cnt] == 'V')
  91. drawTriangleV(edgeLenght / 2, x, y + 2 * edgeLenght * 1.72 / 6);
  92. }
  93. }
  94.  
  95. line(x - edgeLenght / 2, y - edgeLenght * 1.72 / 6, x + edgeLenght / 2, y - edgeLenght * 1.72 / 6);
  96. if(ok){
  97. cnt += 2;
  98. if(s[cnt + 1] == ')')
  99. ok = 0;
  100. if(s[cnt] != '#'){
  101. if(s[cnt] == 'A')
  102. drawTriangleA(edgeLenght / 2, x - edgeLenght / 2, y - edgeLenght * 1.72 / 6);
  103. else if(s[cnt] == 'V')
  104. drawTriangleV(edgeLenght / 2, x - edgeLenght / 2, y - edgeLenght * 1.72 / 6);
  105. }
  106. }
  107. }
  108.  
  109. int main(){
  110.  
  111. initwindow(LMAX, HMAX, "The Beauty of Code", 250, 50);
  112.  
  113. //freopen("triunghi.txt", "w", stdout);
  114. freopen("triunghi.in", "r", stdin);
  115.  
  116. scanf("%s", s);
  117.  
  118. cnt = 0;
  119. drawTriangleV(300, LMAX / 2, HMAX / 2);
  120.  
  121. getch();
  122. closegraph();
  123.  
  124. return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement