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
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Label3: TLabel;
StringGrid1: TStringGrid;
Label4: TLabel;
StringGrid2: TStringGrid;
Button2: TButton;
Label5: TLabel;
StringGrid3: TStringGrid;
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
matr1=array[1..26,1..26] of Real;
matr2=array[1..16,1..16] of Real;
vect=array[1..26] of Real;
var
Form1: TForm1;
n:Integer;
k:Integer;
a:matr1;
b:matr2;
y:vect;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
c:real;
begin
n:=StrToInt(Edit1.Text);
StringGrid1.RowCount:=n+1;
StringGrid1.ColCount:=n+1;
for i:=1 to n do
StringGrid1.Cells[0,i]:=IntToStr(i);
StringGrid1.Cells[i,0]:=IntToStr(i);
begin
randomize();
for i:=1 to n do
for j:=1 to n do
begin
if (random(2) = 0) then c:=1
else c:=-1;
StringGrid1.Cells[j,i]:=FloatToStr(c*random(50));
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j:integer;
c:real;
begin
k:=StrToInt(Edit2.Text);
StringGrid2.RowCount:=k+1;
StringGrid2.ColCount:=k+1;
for i:=1 to k do
StringGrid2.Cells[0,i]:=IntToStr(i);
StringGrid2.Cells[i,0]:=IntToStr(i);
begin
randomize();
for i:=1 to k do
for j:=1 to k do
begin
if (random(2) = 0) then c:=1
else c:=-1;
StringGrid2.Cells[j,i]:=FloatToStr(c*random(50));
end;
end;
end;
procedure max1(n:Integer;a:matr1);
var i,j:Integer; max:real;
begin
max:=a[1,1];
for i:=1 to n do
for j:=1 to n do
if max<a[i,j]
then max:=a[i,j];
end;
procedure min2(k:Integer;b:matr2);
var i,j:Integer; min:Real;
begin
min:=b[1,1];
for i:=1 to k do
for j:=1 to k do
if min>b[i,j]
then min:=b[i,j];
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
n:=StrToInt(Edit1.text);
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
k:=StrToInt(Edit1.text);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
n:=2;
k:=2;
StringGrid1.Visible:=False;
StringGrid2.Visible:=False;
StringGrid3.Visible:=False;
end;
procedure TForm1.Button2Click(Sender: TObject);
var o,p,n,k:Integer;
begin
if max1(n,a)>min2(k,b) then
for o:=1 to n do
stringgrid3.Cells[1,o]:=FloatToStr(a[o,o]);
else
begin
for p:=1 to k do
stringgrid3.cells[1,p]:=floattostr(b[p,k-p+1);
end;
end. |