unit Unit1 interface uses Windows Messages SysUtils Variants Classes G

 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
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Menus;
type
TForm1 = class(TForm)
S1: TStringGrid;
MainMenu1: TMainMenu;
OBRABOTKO1: TMenuItem;
SYMMA1: TMenuItem;
PROIZVEDENIE1: TMenuItem;
MAX1: TMenuItem;
MIN1: TMenuItem;
procedure FormActivate(Sender: TObject);
procedure SYMMA1Click(Sender: TObject);
procedure PROIZVEDENIE1Click(Sender: TObject);
procedure MAX1Click(Sender: TObject);
procedure MIN1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
i,j,k:byte;
a:array [0..10] of integer;
max,MIN,S,P:integer;
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
randomize;
s1.ColCount:=strtoint(inputbox('vvod','stolbci',''));
s1.rowCount:=strtoint(inputbox('vvod','stroki',''));
for i:=0 to s1.rowcount-1 do
for j:=0 to s1.colcount-1 do
s1.Cells[j,i]:=inttostr(random(10)-5);
end;
procedure TForm1.SYMMA1Click(Sender: TObject);
begin
S:=0;
for i:=0 to s1.rowcount-1 do
for j:=0 to s1.colcount-1 do
IF STRTOINT(S1.Cells[J,I])<0 THEN
S:=S+STRTOINT(S1.CELLS[J,I]);
SHOWMESSAGE(INTTOSTR(S));
end;
procedure TForm1.PROIZVEDENIE1Click(Sender: TObject);
begin
P:=1;
for i:=0 to s1.rowcount-1 do
for j:=0 to s1.colcount-1 do
IF STRTOINT(S1.Cells[J,I])<0 THEN
P:=P*STRTOINT(S1.CELLS[J,I]);
SHOWMESSAGE(INTTOSTR(P));
end;
procedure TForm1.MAX1Click(Sender: TObject);
begin
MAX:=-10000;
for i:=0 to s1.rowcount-1 do
for j:=0 to s1.colcount-1 do
IF (STRTOINT(S1.Cells[J,I])>MAX) AND(STRTOINT(S1.Cells[J,I])<0) THEN
MAX:= STRTOINT( S1.Cells[J,I]);
SHOWMESSAGE(INTTOSTR(MAX));
end;
procedure TForm1.MIN1Click(Sender: TObject);
begin
MIN:=0;
for i:=0 to s1.rowcount-1 do
for j:=0 to s1.colcount-1 do
IF (STRTOINT(S1.Cells[J,I])<MIN) AND(STRTOINT(S1.Cells[J,I])<0)THEN
MIN:= STRTOINT( S1.Cells[J,I]);
SHOWMESSAGE(INTTOSTR(MIN));
end;
end.