unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, System.ComponentModel, Borland.Vcl.StdCtrls,
  System.Collections;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.nfm}

procedure TForm1.Button1Click(Sender: TObject);
const rozmiar :Integer =100;
const i5 :array[1..5] of Integer =(-1,-1,-1,-1,-1);
var
  a :ArrayList;
  i :Integer;
  a0 :array[1..100] of Integer;
  a1 :array[1..10] of Integer;
  ai :Integer;
begin
a:=System.Collections.ArrayList.Create(a0);
for i:=0 to rozmiar-1 do a[i]:=TObject(Random(100));
a.AddRange(a1);
a.InsertRange(rozmiar div 2,i5);
a.Insert(0,TObject(System.Int32(-2)));

i:=0;
repeat
  if Integer(a.Item[i])>20
    then a.RemoveAt(i)
    else Inc(i);
until not (i<a.Count);


a.Sort;
for ai in a do listBox1.Items.Add(IntToStr(ai));
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  artysci :SortedList;
  komunikat :String;
  artysta :DictionaryEntry;
begin
artysci:=SortedList.Create;
artysci.Add('Sting','Gordon Matthew Sumner');
artysci.Add('Bolesław Prus','Aleksander Głowacki');
artysci.Add('Pola Negri','Barbara Apolonia Chałupiec');
artysci.Add('John Wayne','Marion Michael Morrison');
artysci.Add('Chico','Leonard Marx');
artysci.Add('Harpo','Arthur Marx');
artysci.Add('Groucho','Julius Marx');
artysci.Add('Bono','Paul Hewson');
artysci.Add('Ronaldo','Luiz Nazario de Lima');
artysci.Add('Madonna','Madonna Louise Veronica Ciccone');
artysci.Add('Gabriela Zapolska','Maria G. Śnieżko-Błocka');

komunikat:='Zawartość listy:'+#13+#13;
for artysta in artysci do
   komunikat:=komunikat+artysta.Key.ToString+' - '+artysta.Value.ToString+#13;
ShowMessage(komunikat);
end;

end.
