unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, unit2;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Edit1: TEdit;
Button3: TButton;
Button4: TButton;
ListBox2: TListBox;
ListBox3: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Lst: TList;


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
c: integer;
begin
c:=StrToInt(Edit1.Text);
Listbox1.Items.Add(Edit1.Text);
Lst.Addk(c);
inc(Lst.nm_zap);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Lst:=Tlist.Create;
Lst.nm_zap:=0;
end;



procedure TForm1.Button3Click(Sender: TObject);
var
c:integer;
begin
c:=0;
Randomize;
while c=0 do c:=Random(10);
Listbox1.Items.Add(inttostr(c));
Lst.Addk(c);
inc(Lst.nm_zap);
end;

procedure TForm1.Button4Click(Sender: TObject);
var
b,i,tmp,num:integer;
rez1,rez2:string;
a:array[0..20] of integer;
begin
num:=0;
tmp:=0;
rez1:=Lst.Ariphm2(1);

for i:=0 to 20 do a[i]:=0;
for i:=1 to length(rez1) do
if copy(rez1,i,1)<>' ' then a[num]:= a[num]*10+strtoint(copy(rez1,i,1))
else
begin
if copy(rez1,i,1)=' ' then {continue;}
inc(num);
end;
for i:=0 to 20 do
if a[i]<>0 then
begin
listbox2.Items.Strings[i]:=inttostr(a[i]);
end;

num:=0;
tmp:=0;
rez2:=Lst.Ariphm2(2);

for i:=0 to 20 do a[i]:=0;
for i:=1 to length(rez2) do
if copy(rez2,i,1)<>' ' then a[num]:= a[num]*10+strtoint(copy(rez2,i,1))
else
begin
if copy(rez2,i,1)=' ' then inc(num);
end;
for i:=0 to 20 do
if a[i]<>0 then
begin
listbox3.Items.Strings[i]:=inttostr(a[i]);
end;
end;

end.
Соседние файлы в папке чётн,нечётн, добавление эелемента