Sabtu, 19 November 2016

Operasi Pada Himpunan Menggunakan Delphi

procedure THimpunan.Panel2Click(Sender: TObject);
begin
  ListBox2.Items.Add(Edit1.Text);
  Edit1.Text:='';

end;

procedure THimpunan.Panel3Click(Sender: TObject);
begin
ListBox3.Items.Add(Edit2.Text);
  Edit2.Text:='';

end;

procedure THimpunan.Panel4Click(Sender: TObject);
begin
ListBox8.Items.Add(Edit3.Text);
  Edit3.Text:='';

end;

procedure THimpunan.Panel5Click(Sender: TObject);
var
  x,y:Integer;
  a,b:Array[0..100] of String;

begin
  For x:=0 to ListBox2.Items.Count-1 do
    a[x]:=ListBox2.Items[x];

  For y:=0 to ListBox3.Items.Count-1 do
    b[y]:=ListBox3.Items[y];

  For x:=0 to ListBox2.Items.Count-1 do
    begin
      For y:=0 to ListBox3.Items.Count-1 do
      if a[x]=b[y] then ListBox1.Items.Add(A[x]);
    end;


end;

procedure THimpunan.Panel6Click(Sender: TObject);
var
  x,y:Integer;
  a,b:Array[0..100] of String;
  p:Boolean;

begin
  For x:=0 to ListBox2.Items.Count-1 do
    a[x]:=ListBox2.Items[x];

  For y:=0 to ListBox3.Items.Count-1 do
    b[y]:=ListBox3.Items[y];

  For x:=0 to ListBox2.Items.Count-1 do
    ListBox4.Items.Add(A[x]);

  For y:=0 to ListBox3.Items.Count-1 do
    begin
      p:=false;

      For x:=0 to ListBox2.Items.Count-1 do
        if a[x]=b[y] then p:=true;
          if p=false then ListBox4.Items.Add(b[y]);
    end;


end;

procedure THimpunan.Panel7Click(Sender: TObject);
Var x,y:Integer;
    a,b:Array[0..100] of String;
    p:Boolean;
begin
    For x:=0 to ListBox2.Items.Count-1 do
    a[x]:=ListBox2.Items[x];
    For y:=0 to ListBox3.Items.Count-1 do
    b[y]:=ListBox3.Items[y];
    For x:=0 to ListBox2.Items.Count-1 do
    begin
      p:=false;
      For y:=0 to ListBox3.Items.Count-1 do
      if a[x]=b[y] then p:=true;
      if p=false then ListBox5.Items.Add(a[x]);
    end;
    For y:=0 to ListBox3.Items.Count-1 do
    begin
      p:=false;
      For x:=0 to ListBox2.Items.Count-1 do
      if a[x]=b[y] then p:=true;
      if p=false then ListBox5.Items.Add(b[y]);
    end;


end;

procedure THimpunan.Panel8Click(Sender: TObject);
var
  x,y:Integer;
  a,b:Array[0..100] of String;
  p:Boolean;

begin
  For x:=0 to ListBox2.Items.Count-1 do
    a[x]:=ListBox2.Items[x];

  For y:=0 to ListBox3.Items.Count-1 do
    b[y]:=ListBox3.Items[y];

  For x:=0 to ListBox2.Items.Count-1 do
    begin
      p:=false;
      For y:=0 to ListBox3.Items.Count-1 do
        if a[x]=b[y] then p:=true;
          if p=false then ListBox6.Items.add(A[x]);
    end;



end;

procedure THimpunan.Panel9Click(Sender: TObject);
var
  i,j:integer;
  A,B:Array [0..100] of string;
  ada:boolean;
begin
for i:=0 to listbox2.Items.Count-1 do
A[i]:=listbox2.Items[i];

for j:=0 to listbox8.items.count-1 do
B[j]:=listbox8.items[j];


for j:=0 to listbox8.Items.Count-1 do
begin
ada:=true;
for i:=0 to listbox8.Items.count-1 do
if B[j]=A[i] then ada:=false;
if ada=true then listbox7.Items.add(B[j]);


 end;

end;

procedure THimpunan.Panel10Click(Sender: TObject);
begin
Edit1.Text:=' ';
Edit2.Text:=' ';
Edit3.Text:=' ';
listbox1.Items.Clear;
listbox2.Items.Clear;
listbox3.Items.Clear;
listbox4.Items.Clear;
listbox5.Items.Clear;
listbox6.Items.Clear;
listbox7.Items.Clear;
listbox8.Items.Clear;

end;

procedure THimpunan.Panel11Click(Sender: TObject);
begin
MainMenu.Show;
Himpunan.Hide;

end;

end.

0 komentar:

Posting Komentar