unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 =
class
(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
StringGrid1: TStringGrid;
Label2: TLabel;
Edit2: TEdit;
Button2: TButton;
StringGrid2: TStringGrid;
Label3: TLabel;
Edit3: TEdit;
Button3: TButton;
StringGrid3: TStringGrid;
Button4: TButton;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit4: TEdit;
Label8: TLabel;
Edit5: TEdit;
Label9: TLabel;
Edit6: TEdit;
procedure
Button1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
procedure
Button3Click(Sender: TObject);
procedure
Button4Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
type
myarr =
array
of
real
;
implementation
{$R *.dfm}
procedure
DoubleX(
var
A: myarr;
var
N:
integer
; X:
real
);
var
i,j, num:
integer
;
tempmas: myarr;
begin
num :=
0
;
for
I :=
0
to
N -
1
do
if
A[i] = x
then
inc(num);
setlength(tempmas, N+num);
j :=
0
;
for
I :=
0
to
N -
1
do
begin
tempmas[j] := A[i];
inc(j);
if
a[i] = x
then
begin
tempmas[j] := a[i];
inc(j);
end
;
end
;
a := tempmas;
n := n+num;
end
;
procedure
TForm1
.
Button1Click(Sender: TObject);
var
i:
integer
;
begin
randomize;
StringGrid1
.
ColCount := strtoint(edit1
.
text);
for
I :=
0
to
StringGrid1
.
ColCount -
1
do
StringGrid1
.
Cells[i,
0
] := floattostr(round(random*
255
));
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
i:
integer
;
begin
randomize;
StringGrid2
.
ColCount := strtoint(edit2
.
text);
for
I :=
0
to
StringGrid2
.
ColCount -
1
do
StringGrid2
.
Cells[i,
0
] := floattostr(round(random*
255
));
end
;
procedure
TForm1
.
Button3Click(Sender: TObject);
var
i:
integer
;
begin
randomize;
StringGrid3
.
ColCount := strtoint(edit3
.
text);
for
I :=
0
to
StringGrid3
.
ColCount -
1
do
StringGrid3
.
Cells[i,
0
] := floattostr(round(random*
255
));
end
;
procedure
TForm1
.
Button4Click(Sender: TObject);
var
a,b,c: myarr;
a1,b1,c1,i:
integer
;
begin
setlength(a,StringGrid1
.
ColCount);
SetLength(b,StringGrid2
.
ColCount);
SetLength(c,StringGrid3
.
ColCount);
for
I :=
0
to
StringGrid1
.
ColCount -
1
do
a[i] := strtofloat(StringGrid1
.
cells[i,
0
]);
for
I :=
0
to
StringGrid2
.
ColCount -
1
do
b[i] := strtofloat(StringGrid2
.
cells[i,
0
]);
for
I :=
0
to
StringGrid3
.
ColCount -
1
do
c[i] := strtofloat(StringGrid3
.
cells[i,
0
]);
i:= stringgrid1
.
colcount;
doublex(a, i, strtofloat(edit4
.
Text));
StringGrid1
.
ColCount := i;
i:= stringgrid2
.
colcount;
doublex(b, i, strtofloat(edit5
.
Text));
StringGrid2
.
ColCount := i;
i:= stringgrid3
.
colcount;
doublex(c, i, strtofloat(edit6
.
Text));
StringGrid3
.
ColCount := i;
for
I :=
0
to
StringGrid1
.
ColCount -
1
do
stringgrid1
.
Cells[i,
0
] := floattostr(a[i]);
for
I :=
0
to
StringGrid2
.
ColCount -
1
do
stringgrid2
.
Cells[i,
0
] := floattostr(b[i]);
for
I :=
0
to
StringGrid3
.
ColCount -
1
do
stringgrid3
.
Cells[i,
0
] := floattostr(c[i]);
end
;
end
.