home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D4.DMS / in.adf / Beispiele / BirthdayAVLTrees.mod < prev    next >
Encoding:
Text File  |  1992-10-10  |  1.2 KB  |  52 lines

  1. MODULE BirthdayAVLTrees;
  2.  
  3. IMPORT AVLTrees, io;
  4.  
  5. TYPE
  6.   Person = POINTER TO PersonDesc;
  7.   PersonDesc = RECORD (AVLTrees.SNodeDesc)
  8.     birthday: ARRAY 20 OF CHAR;
  9.   END;
  10.  
  11. VAR
  12.   root: AVLTrees.SRoot;
  13.   node: AVLTrees.SNode;
  14.   new: Person;
  15.   eingabe: ARRAY 20 OF CHAR;
  16.   name: AVLTrees.String;
  17.  
  18. BEGIN
  19.   root := AVLTrees.SCreate();
  20.   REPEAT
  21.     io.WriteLn;
  22.     io.WriteString("  N: Neue Person\n");
  23.     io.WriteString("  G: Geburtstag ausgeben\n");
  24.     io.WriteString("  E: Ende\n\n");
  25.     io.WriteString("Eingabe: ");
  26.     io.ReadString(eingabe);
  27.     io.WriteLn;
  28.     IF (eingabe="n") OR (eingabe="g") THEN
  29.       io.WriteString("Name der Person: ");
  30.       io.ReadString(name);
  31.       IF eingabe="n" THEN
  32.         NEW(new); new.name := name;
  33.         io.WriteString("Geburtstag: ");
  34.         io.ReadString(new.birthday);
  35.         root.Add(new);
  36.         IF ~ root.addOk THEN
  37.           io.WriteString("Person existiert bereits!\n");
  38.         END;
  39.       ELSE
  40.         node := root.SFind(name);
  41.         IF node=NIL THEN
  42.           io.WriteString("Person nicht gefunden!\n");
  43.         ELSE
  44.           io.WriteString("Geburtstag: ");
  45.           io.WriteString(node(Person).birthday);
  46.           io.WriteLn;
  47.         END;
  48.       END;
  49.     END;
  50.   UNTIL eingabe="e";
  51. END BirthdayAVLTrees.
  52.