summaryrefslogtreecommitdiff
path: root/unit1.pas
diff options
context:
space:
mode:
Diffstat (limited to 'unit1.pas')
-rw-r--r--unit1.pas124
1 files changed, 124 insertions, 0 deletions
diff --git a/unit1.pas b/unit1.pas
new file mode 100644
index 0000000..86792d7
--- /dev/null
+++ b/unit1.pas
@@ -0,0 +1,124 @@
+unit Unit1;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
+ Unit2;
+
+type
+
+ { TForm1 }
+
+ TForm1 = class(TForm)
+ Button1: TButton;
+ Label1: TLabel;
+ Label2: TLabel;
+ Label3: TLabel;
+ ListBox1: TListBox;
+ ListBox2: TListBox;
+ Memo1: TMemo;
+ Memo2: TMemo;
+ Memo3: TMemo;
+ procedure Button1Click(Sender: TObject);
+ procedure FormClick(Sender: TObject);
+ procedure FormCreate(Sender: TObject);
+ procedure FormDestroy(Sender: TObject);
+ procedure FormResize(Sender: TObject);
+ procedure ListBox1Click(Sender: TObject);
+ private
+ { private declarations }
+ public
+ { public declarations }
+ loesungen: tLoesungArray;
+ Rs,Cs: tMyExtendedArray;
+ end;
+
+var
+ Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.FormResize(Sender: TObject);
+begin
+ Memo1.Height:=Form1.ClientHeight-Memo1.Top;
+ Memo2.Height:=Form1.ClientHeight-Memo2.Top;
+ Memo3.Height:=Form1.ClientHeight-Memo3.Top;
+ ListBox1.Height:=Form1.ClientHeight-ListBox1.Top;
+ ListBox2.Height:=Form1.ClientHeight-ListBox2.Top;
+end;
+
+procedure TForm1.ListBox1Click(Sender: TObject);
+begin
+ if (Listbox1.Itemindex>=0) and
+ (Listbox1.Itemindex<length(loesungen.inhalt)) then
+ loesungen.inhalt[Listbox1.Itemindex].anzeigen(Listbox2.Items);
+end;
+
+procedure TForm1.Button1Click(Sender: TObject);
+var
+ hps,tps,thps: tMyExtendedArray;
+begin
+ Rs.free;
+ Rs:=liesExtendedArray(Memo2.Lines);
+ Cs.free;
+ Cs:=liesExtendedArray(Memo1.Lines);
+ tps:=liesExtendedArray(Memo3.Lines,'tp');
+ hps:=liesExtendedArray(Memo3.Lines,'hp');
+ thps:=liesExtendedArray(Memo3.Lines,'thp');
+ ListBox1.Items.Clear;
+ ListBox2.Items.Clear;
+
+ loesungen:=bruteForcen(tps,hps,thps,Cs,Rs,20,@FormClick);
+ loesungen.indexVeroeffentlichen(Listbox1.Items);
+
+ hps.free;
+ tps.free;
+ thps.free;
+end;
+
+const
+ c1: longint = 0;
+ c2: longint = 0;
+
+procedure TForm1.FormClick(Sender: TObject);
+begin
+ if assigned(sender) and
+ (sender is tLoesung) then begin
+ inc(c1);
+ if c1>=1000000 then begin
+ c1:=0;
+ Form1.Caption:=inttostr(c2)+' '+(sender as tLoesung).dumpWeite;
+ Application.ProcessMessages;
+ end;
+ end
+ else begin
+ inc(c2);
+ if c2 mod 100 = 0 then begin
+ Form1.Color:=random($1000000);
+ Form1.Caption:=inttostr(c2)+' '+rightstr(Form1.Caption,length(Form1.Caption)-pos(' ',Form1.Caption));
+ Application.ProcessMessages;
+ end;
+ end;
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+ Rs:=nil;
+ Cs:=nil;
+end;
+
+procedure TForm1.FormDestroy(Sender: TObject);
+begin
+ Rs.free;
+ Cs.free;
+end;
+
+end.
+