1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
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);
procedure iterationsCallBack(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure loesungsCallBack(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
loesungen: tLoesungArray;
Rs,Cs: tMyExtendedArray;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
uses unit3, unit4;
{ 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,@iterationsCallBack,@loesungsCallBack);
loesungen.indexVeroeffentlichen(Listbox1.Items);
hps.free;
tps.free;
thps.free;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
form2.showModal;
end;
const
c1: longint = 0;
c2: longint = 0;
procedure TForm1.iterationsCallBack(Sender: TObject);
begin
inc(c1);
if c1 > 1000000 then begin
c1:=0;
Form1.Caption:=inttostr(c2)+' '+(sender as tLoesung).dumpWeite;
Application.ProcessMessages;
end;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
if (Listbox1.Itemindex>=0) and
(Listbox1.Itemindex<length(loesungen.inhalt)) then begin
form3.loesung.free;
form3.loesung:=tLoesung.create(loesungen.inhalt[listBox1.itemIndex]);
form3.showModal;
end;
end;
procedure TForm1.loesungsCallBack(Sender: TObject);
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;
procedure TForm1.FormCreate(Sender: TObject);
begin
Rs:=nil;
Cs:=nil;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Rs.free;
Cs.free;
end;
end.
|