Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. program Aufgabe(input, output);
  2.  
  3. type
  4. tRefBinBaum = ^tBinBaum;
  5. tBinBaum = record
  6. wert:integer;
  7. links:tRefBinBaum;
  8. rechts:tRefBinBaum
  9. end;
  10.  
  11. var
  12. baumA:tRefBinBaum;
  13. baumB:tRefBinBaum;
  14.  
  15. function check(A : tRefBinBaum; B : tRefBinBaum):boolean;
  16. begin
  17. if (A = nil and B = nil) then
  18. check := true
  19. else if (A = nil and B <> nil) then
  20. check := false
  21. else if A <> nil and B = nil then
  22. check := false
  23. else if A^.wert <> B^.wert then
  24. check := false
  25. else
  26. check := (check(A^.links, B^.links) and check(A^.rechts, B^.rechts))
  27. or (check(A^.links, B^.rechts) and check (A^.rechts, B^.links));
  28. end; {check}
  29.  
  30.  
  31. function testBaum4():tRefBinBaum;
  32. var
  33. b:tRefBinBaum;
  34.  
  35. begin
  36. new(b);
  37. b^.wert := 1;
  38.  
  39. new(b^.links);
  40. new(b^.rechts);
  41. b^.links^.wert := 2;
  42. b^.rechts^.wert := 9;
  43.  
  44. b := b^.rechts;
  45. new(b^.links);
  46. b^.links^.wert:=4;
  47.  
  48. testBaum4 := b;
  49. end;
  50.  
  51. function testBaum3():tRefBinBaum;
  52. var
  53. b:tRefBinBaum;
  54.  
  55. begin
  56. new(b);
  57. b^.wert := 1;
  58. new(b^.links);
  59. new(b^.rechts);
  60. b^.links^.wert := 9;
  61. b^.rechts^.wert := 2;
  62. b := b^.links;
  63. new(b^.links);
  64. new(b^.rechts);
  65. b^.links^.wert:=4;
  66. b^.rechts^.wert :=5;
  67.  
  68. testBaum3 := b;
  69. end;
  70.  
  71. function testBaum2():tRefBinBaum;
  72. var
  73. b:tRefBinBaum;
  74.  
  75. begin
  76. new(b);
  77. b^.wert := 1;
  78. new(b^.links);
  79. new(b^.rechts);
  80. b^.links^.wert := 9;
  81. b^.rechts^.wert := 2;
  82. b := b^.rechts;
  83. new(b^.links);
  84. new(b^.rechts);
  85. b^.links^.wert:=4;
  86. b^.rechts^.wert :=5;
  87.  
  88. testBaum2 := b;
  89. end;
  90.  
  91. function testBaum1():tRefBinBaum;
  92. var
  93. b:tRefBinBaum;
  94.  
  95. begin
  96. new(b);
  97. b^.wert := 1;
  98. new(b^.links);
  99. new(b^.rechts);
  100. b^.links^.wert := 2;
  101. b^.rechts^.wert := 9;
  102. b := b^.rechts;
  103. new(b^.links);
  104. new(b^.rechts);
  105. b^.links^.wert:=4;
  106. b^.rechts^.wert :=5;
  107.  
  108. testBaum1 := b;
  109. end;
  110.  
  111. begin
  112. baumA:=nil;
  113. baumB:=nil;
  114. check(baumA,baumB);
  115. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement