Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <graphics.h>
- #include <winbgim.h>
- using namespace std;
- const int MMAX = 500;
- const int LMAX = 800;
- const int HMAX = 600;
- const int NMAX = 100;
- int N, R = 300, cnt;
- int x_1, y_1, x_2, y_2;
- int ans[MMAX][4];
- char s[NMAX];
- int drawTriangleV(int, int, int);
- int drawTriangleA(int edgeLenght, int x, int y){
- int ok = 0;
- if(s[cnt + 1] == '(')
- ok = 1;
- line(x, y - 2 * edgeLenght * 1.72 / 6, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- if(ok){
- cnt += 2;
- if(s[cnt + 1] == ')')
- ok = 0;
- if(s[cnt] != '#'){
- if(s[cnt] == 'A')
- drawTriangleA(edgeLenght / 2, x, y - 2 * edgeLenght * 1.72 / 6);
- else if(s[cnt] == 'V')
- drawTriangleV(edgeLenght / 2, x, y - 2 * edgeLenght * 1.72 / 6);
- }
- }
- line(x - edgeLenght / 2, y + edgeLenght * 1.72 / 6, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- if(ok){
- cnt += 2;
- if(s[cnt + 1] == ')')
- ok = 0;
- if(s[cnt] != '#'){
- if(s[cnt] == 'A')
- drawTriangleA(edgeLenght / 2, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- else if(s[cnt] == 'V')
- drawTriangleV(edgeLenght / 2, x + edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- }
- }
- line(x, y - 2 * edgeLenght * 1.72 / 6, x - edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- if(ok){
- cnt += 2;
- if(s[cnt + 1] == ')')
- ok = 0;
- if(s[cnt] != '#'){
- if(s[cnt] == 'A')
- drawTriangleA(edgeLenght / 2, x - edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- else if(s[cnt] == 'V')
- drawTriangleV(edgeLenght / 2, x - edgeLenght / 2, y + edgeLenght * 1.72 / 6);
- }
- }
- }
- int drawTriangleV(int edgeLenght, int x, int y){
- int ok = 0;
- if(s[cnt + 1] == '(')
- ok = 1;
- line(x + edgeLenght / 2, y - edgeLenght * 1.72 / 6, x, y + 2 * edgeLenght * 1.72 / 6);
- if(ok){
- cnt += 2;
- if(s[cnt + 1] == ')')
- ok = 0;
- if(s[cnt] != '#'){
- if(s[cnt] == 'A')
- drawTriangleA(edgeLenght / 2, x + edgeLenght / 2, y - edgeLenght * 1.72 / 6);
- else if(s[cnt] == 'V')
- drawTriangleV(edgeLenght / 2, x + edgeLenght / 2, y - edgeLenght * 1.72 / 6);
- }
- }
- line(x - edgeLenght / 2, y - edgeLenght * 1.72 / 6, x, y + 2 * edgeLenght * 1.72 / 6);
- if(ok){
- cnt += 2;
- if(s[cnt + 1] == ')')
- ok = 0;
- if(s[cnt] != '#'){
- if(s[cnt] == 'A')
- drawTriangleA(edgeLenght / 2, x, y + 2 * edgeLenght * 1.72 / 6);
- else if(s[cnt] == 'V')
- drawTriangleV(edgeLenght / 2, x, y + 2 * edgeLenght * 1.72 / 6);
- }
- }
- line(x - edgeLenght / 2, y - edgeLenght * 1.72 / 6, x + edgeLenght / 2, y - edgeLenght * 1.72 / 6);
- if(ok){
- cnt += 2;
- if(s[cnt + 1] == ')')
- ok = 0;
- if(s[cnt] != '#'){
- if(s[cnt] == 'A')
- drawTriangleA(edgeLenght / 2, x - edgeLenght / 2, y - edgeLenght * 1.72 / 6);
- else if(s[cnt] == 'V')
- drawTriangleV(edgeLenght / 2, x - edgeLenght / 2, y - edgeLenght * 1.72 / 6);
- }
- }
- }
- int main(){
- initwindow(LMAX, HMAX, "The Beauty of Code", 250, 50);
- //freopen("triunghi.txt", "w", stdout);
- freopen("triunghi.in", "r", stdin);
- scanf("%s", s);
- cnt = 0;
- drawTriangleV(300, LMAX / 2, HMAX / 2);
- getch();
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement