Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Aufgabe(input, output);
- type
- tRefBinBaum = ^tBinBaum;
- tBinBaum = record
- wert:integer;
- links:tRefBinBaum;
- rechts:tRefBinBaum
- end;
- var
- baumA:tRefBinBaum;
- baumB:tRefBinBaum;
- function check(A : tRefBinBaum; B : tRefBinBaum):boolean;
- begin
- if (A = nil and B = nil) then
- check := true
- else if (A = nil and B <> nil) then
- check := false
- else if A <> nil and B = nil then
- check := false
- else if A^.wert <> B^.wert then
- check := false
- else
- check := (check(A^.links, B^.links) and check(A^.rechts, B^.rechts))
- or (check(A^.links, B^.rechts) and check (A^.rechts, B^.links));
- end; {check}
- function testBaum4():tRefBinBaum;
- var
- b:tRefBinBaum;
- begin
- new(b);
- b^.wert := 1;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert := 2;
- b^.rechts^.wert := 9;
- b := b^.rechts;
- new(b^.links);
- b^.links^.wert:=4;
- testBaum4 := b;
- end;
- function testBaum3():tRefBinBaum;
- var
- b:tRefBinBaum;
- begin
- new(b);
- b^.wert := 1;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert := 9;
- b^.rechts^.wert := 2;
- b := b^.links;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert:=4;
- b^.rechts^.wert :=5;
- testBaum3 := b;
- end;
- function testBaum2():tRefBinBaum;
- var
- b:tRefBinBaum;
- begin
- new(b);
- b^.wert := 1;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert := 9;
- b^.rechts^.wert := 2;
- b := b^.rechts;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert:=4;
- b^.rechts^.wert :=5;
- testBaum2 := b;
- end;
- function testBaum1():tRefBinBaum;
- var
- b:tRefBinBaum;
- begin
- new(b);
- b^.wert := 1;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert := 2;
- b^.rechts^.wert := 9;
- b := b^.rechts;
- new(b^.links);
- new(b^.rechts);
- b^.links^.wert:=4;
- b^.rechts^.wert :=5;
- testBaum1 := b;
- end;
- begin
- baumA:=nil;
- baumB:=nil;
- check(baumA,baumB);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement