unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
end.
procedure TForm1.Button1Click(Sender: TObject);
var matriz: array[1..3] of array[1..3] of integer;
matriz2: array[1..9] of integer;
i, i2, i3, j, j2, j3, k, iCount: integer;
sAux: string;
Lista: TStringList;
begin
ListBox1.Clear;
Randomize;
for i := 1 to 3 do begin
for j := 1 to 3 do begin
matriz[i, j] := Random(10);
end;
end;
k := 1;
for i := 1 to 3 do begin
for j := 1 to 3 do begin
TEdit(FindComponent('Edit' + IntToStr(k))).Text := IntToStr(matriz[i, j]);
matriz2[k] := matriz[i, j];
inc(k);
end;
end;
for i := 1 to 9 do begin
for j := {i + }1 to 9 do begin
for k := {j + }1 to 9 do begin
if (k <> i) and (k <> j) and (i <> j) then begin
sAux := IntToStr(matriz2[i]) + ' - ' + IntToStr(matriz2[j]) + ' - ' + IntToStr(matriz2[k]);
ListBox1.Items.Add(sAux);
end;
end;
end;
end;
ListBox2.Items.Clear;
Lista := TStringList.Create;
ListBox2.Items.AddStrings(ListBox1.Items);
ListBox2.Sorted := true;
try
while ListBox2.Items.Count > 0 do begin
iCount := 1;
sAux := ListBox2.Items[0];
ListBox2.Items.Delete(0);
while (ListBox2.Items.Count > 0) and (sAux = ListBox2.Items[0]) do begin
ListBox2.Items.Delete(0);
inc(iCount);
end;
Lista.Add(format('%.3d', [iCount]) + ': ' + sAux);
end;
except
ShowMessage(IntToStr(i) + ' - ' + IntToStr(j));
end;
Lista.Sort;
ListBox2.Items.Clear;
ListBox2.Items.AddStrings(Lista);
Lista.Free;
Edit10.Text := IntToStr(ListBox1.Items.Count);
end;