Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /*
  6. fin = open("input.txt")
  7. fout = open("output.txt", "w")
  8.  
  9. a = []
  10. b = fin.readlines()
  11. for r in b:
  12. l = r.split()
  13. for i in range(len(l)):
  14. a.append(int(l[i]))
  15. n = a[0]
  16. w = max(a[1:]) * 2 + 1
  17. h = 0
  18.  
  19. for i in range(1, n+1):
  20. h += a[i] * 2 + 1
  21. h -= 2
  22. h += 2
  23.  
  24. f = []
  25. for i in range(h):
  26. f.append(["."] * w)
  27.  
  28. def draw(x, y, d, c):
  29. i = 0
  30. while i < d:
  31. f[x][y+i] = c
  32. f[x][y-i] = c
  33. x += 1
  34. i+=1
  35. while i >= 0:
  36. f[x][y+i] = c
  37. f[x][y-i] = c
  38. x += 1
  39. i-=1
  40.  
  41. char = ["*", "#"]
  42.  
  43. m = w // 2
  44. t = 0
  45. for i in range(1, n+1):
  46. draw(t, m, a[i], char[i % 2])
  47. t += a[i] * 2 + 1
  48. t-= 2
  49. for i in range(h):
  50. for j in range(w):
  51. fout.write(f[i][j])
  52. fout.write("\n")
  53.  
  54.  
  55. fin.close()
  56. fout.close()
  57. */
  58.  
  59. vector<vector<char>> f;
  60.  
  61. int main () {
  62. // freopen("input.txt", "r", stdin);
  63. // freopen("output.txt", "w", stdout);
  64.  
  65. int n;
  66. cin >> n;
  67.  
  68. int a[101];
  69. int w = 0, h = 0;
  70. for (int i = 1; i <= n; i++) {
  71. cin >> a[i];
  72. w = max(a[i], w);
  73. h += a[i] * 2 + 1;
  74. h -= 2;
  75. }
  76. h += 2;
  77. w = w * 2 + 1;
  78.  
  79. f.resize(h,vector<char>(w));
  80. char = ["*", "#"]
  81.  
  82. m = w // 2
  83. t = 0
  84. for i in range(1, n+1):
  85. draw(t, m, a[i], char[i % 2])
  86. t += a[i] * 2 + 1
  87. t-= 2
  88.  
  89.  
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement