ex39.pp 551 B

1234567891011121314151617181920212223242526
  1. Program ex39;
  2. { Program to demonstrate the TUnsortedStrCollection.Insert method }
  3. Uses Objects,Strings;
  4. Var C : PUnsortedStrCollection;
  5. S : String;
  6. I : longint;
  7. P : Pchar;
  8. begin
  9. Randomize;
  10. C:=New(PUnsortedStrCollection,Init(120,10));
  11. Writeln ('Inserting 100 records at random places.');
  12. For I:=1 to 100 do
  13. begin
  14. Str(Random(100),S);
  15. S:='String with value '+S;
  16. P:=StrAlloc(Length(S)+1);
  17. C^.Insert(StrPCopy(P,S));
  18. end;
  19. For I:=0 to 99 do
  20. Writeln (I:2,': ',PChar(C^.At(i)));
  21. Dispose(C,Done);
  22. end.