Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. program zad_1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. type
  9. t = array [1..4] of integer;
  10.  
  11. var
  12. a, b, c, d: t;
  13. n, i, j, cnt, flag, h, s, f, max1, maxi, min1, mini: integer;
  14.  
  15. function full(var a, b, c, d: t): integer;
  16. begin
  17. maxi := a[1];
  18. for i := 2 to 4 do
  19. if (a[i] > maxi) then
  20. maxi := a[i];
  21. for i := 1 to 4 do
  22. if (b[i] > maxi) then
  23. maxi := b[i];
  24. for i := 1 to 4 do
  25. if (c[i] > maxi) then
  26. maxi := c[i];
  27. for i := 1 to 4 do
  28. if (d[i] > maxi) then
  29. maxi := d[i];
  30. full := maxi;
  31. end;
  32.  
  33. function empty(var a, b, c, d: t): integer;
  34. begin
  35. mini := a[1];
  36. for i := 2 to 4 do
  37. if (a[i] < mini) then
  38. maxi := a[i];
  39. for i := 1 to 4 do
  40. if (b[i] < mini) then
  41. maxi := b[i];
  42. for i := 1 to 4 do
  43. if (c[i] < mini) then
  44. maxi := c[i];
  45. for i := 1 to 4 do
  46. if (d[i] < mini) then
  47. maxi := d[i];
  48. empty := mini;
  49. end;
  50.  
  51. begin
  52. readln(a[1], a[2], a[3], a[4]);
  53. readln(b[1], b[2], b[3], b[4]);
  54. readln(c[1], c[2], c[3], c[4]);
  55. readln(d[1], d[2], d[3], d[4]);
  56. max1 := full(a, b, c, d);
  57. min1 := empty(a, b, c, d);
  58. s := 0;
  59. f := 0;
  60. h := 0;
  61. for i := min1 to max1 do begin
  62. if (a[3] = i) then begin
  63. dec(s);
  64. inc(h);
  65. end;
  66. if (b[3] = i) then begin
  67. dec(s);
  68. inc(h);
  69. end;
  70. if (c[3] = i) then begin
  71. dec(s);
  72. inc(h);
  73. end;
  74. if (d[3] = i) then begin
  75. dec(s);
  76. inc(h);
  77. end;
  78. if (h = 2) and (s = 0) then begin
  79. writeln('Vertical');
  80. writeln(i);
  81. halt;
  82. end;
  83. if (h = 2) and (s <> 0) or (h > 2) or (s > 2) then
  84. break;
  85. if (a[1] = i) then
  86. inc(s);
  87. if (b[1] = i) then
  88. inc(s);
  89. if (c[1] = i) then
  90. inc(s);
  91. if (d[1] = i) then
  92. inc(s);
  93. end;
  94. s := 0;
  95. f := 0;
  96. h := 0;
  97. for i := min1 to max1 do begin
  98. if (a[4] = i) then begin
  99. dec(s);
  100. inc(h);
  101. end;
  102. if (b[4] = i) then begin
  103. dec(s);
  104. inc(h);
  105. end;
  106. if (c[4] = i) then begin
  107. dec(s);
  108. inc(h);
  109. end;
  110. if (d[4] = i) then begin
  111. dec(s);
  112. inc(h);
  113. end;
  114. if (h = 2) and (s = 0) then begin
  115. writeln('Horizontal');
  116. writeln(i);
  117. halt;
  118. end;
  119. if (h = 2) and (s <> 0) or (h > 2) or (s > 2) then
  120. break;
  121. if (a[2] = i) then
  122. inc(s);
  123. if (b[2] = i) then
  124. inc(s);
  125. if (c[2] = i) then
  126. inc(s);
  127. if (d[2] = i) then
  128. inc(s);
  129. end;
  130. writeln('Impossible');
  131. readln;
  132. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement