Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. type massiv = array[1..1000] of byte;
  2.  
  3. var a : massiv;
  4. i, j, n, sc, sc2, ot, k, e, r, e2 : integer;
  5. t1, t2 : boolean;
  6.  
  7. begin
  8. readln(n);
  9. for i := 1 to n do
  10. begin
  11. write('a[', i ,'] = ');
  12. read(a[i]);
  13. end;
  14. for i := 1 to n do
  15. if a[i] = 0 then
  16. begin
  17. j := i;
  18. sc := 0;
  19. repeat
  20. inc(j);
  21. inc(sc);
  22. if (j = n) and (a[j] <> 0) then
  23. begin
  24. sc := 1;
  25. break;
  26. end;
  27. until a[j] = 0;
  28. dec(sc);
  29. if sc2 < sc then
  30. begin
  31. sc2 := sc;
  32. ot := i + 1;
  33. k := j - 1;
  34. end;
  35. end;
  36. writeln(ot, ' ', k, ' - samii boliwoi ostrovok');
  37. for i := ot to k do
  38. if a[i] > e then
  39. begin
  40. e := a[i];
  41. r := i;
  42. end;
  43. writeln(e : 3, r : 3);
  44. e2 := e;
  45. if ot + 1 = r then
  46. begin
  47. if a[ot] < e2 then t1 := true;
  48. end
  49. else
  50. for i := r-1 downto ot+1 do
  51. begin
  52. if a[i]< e2 then e2 := a[i];
  53. if a[i-1]< e2 then t1 := true;
  54. end;
  55. e2 := e;
  56. if r+1 = k then
  57. begin
  58. if a[k] < e2 then t2 := true;
  59. end
  60. else
  61. for i := r+1 to k-1 do
  62. begin
  63. if a[i] < e2 then e2 := a[i];
  64. if a[i+1]< e2 then t2 := true;
  65. end;
  66. if t1 and t2 then writeln('gora');
  67. writeln(t1);
  68. writeln(t2);
  69.  
  70.  
  71.  
  72. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement