Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program einlesenBaum (input, output);
- type
- tRefBinBaum = ^tBinBaum;
- tBinBaum = Record
- Info : integer;
- Links : tRefBinBaum;
- Rechts : tRefBinBaum;
- end;
- var
- Wurzel : tRefBinBaum;
- NewSohn : tRefBinBaum;
- Zeiger : tRefBinBaum;
- Eingabe : integer;
- Eingefugt : boolean;
- begin
- wurzel := NIL;
- write ('Wurzel Wert: ');
- readln (Eingabe);
- while (Eingabe <> 0) do
- begin
- Zeiger := wurzel;
- writeln ('Drinnen');
- if wurzel = nil then
- begin
- new (wurzel);
- Wurzel^.Info := Eingabe;
- Wurzel^.Links := NIL;
- Wurzel^.Rechts := NIL;
- writeln ('Drinnen');
- end
- else
- begin
- writeln ('IN ELSE');
- new (newSohn);
- NewSohn^.Info := Eingabe;
- NewSohn^.Rechts := NIL;
- NewSohn^.Links := NIL;
- {Nun An der richtigen Stelle einfügen}
- if Wurzel^.Info < NewSohn^.Info then
- begin
- if Wurzel^.Rechts = NIL then
- Wurzel^.Rechts := NewSohn;
- else
- begin
- end; {Einfügen}
- end;
- Zeiger := NewSohn;
- writeln (wurzel^.links^.info,'NEW SOHN DONE');
- end; {Neuer Wert wurde eingefügt}
- Write ('Geben Sie den Naechsten Wert ein: ');
- Readln (Eingabe);
- end; {WHILE EINGABE = 0 ENDE}
- Writeln ('Wurzel: ', Wurzel^.Info, ' | Rechts: ',Wurzel^.Rechts^.Info, ' | Links: ', Wurzel^.links^.Info)
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement