Sabiranje matrica (Delphi projekat)
https://zoricabegus.wordpress.com/informatika-iii-razred-pascal-delphi/
unit Matricasabmno;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ExtCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
StringGrid1.ColCount:=StrToInt(edit1.Text)+1;
StringGrid1.RowCount:=StringGrid1.ColCount;
For i:= 0 to stringGrid1.ColCount-1 do StringGrid1.Cells[i,0]:=IntToStr(i);
For i:= 1 to stringGrid1.RowCount-1 do StringGrid1.Cells[0,i]:=IntToStr(i);
StringGrid1.Visible:=true;
StringGrid2.ColCount:=StrToInt(edit1.Text)+1;
StringGrid2.RowCount:=StringGrid2.ColCount;
For i:= 0 to stringGrid2.ColCount-1 do StringGrid2.Cells[i,0]:=IntToStr(i);
For i:= 1 to stringGrid2.RowCount-1 do StringGrid2.Cells[0,i]:=IntToStr(i);
StringGrid2.Visible:=true;
StringGrid3.ColCount:=StrToInt(edit1.Text)+1;
StringGrid3.RowCount:=StringGrid3.ColCount;
For i:= 0 to stringGrid3.ColCount-1 do StringGrid3.Cells[i,0]:=IntToStr(i);
For i:= 1 to stringGrid3.RowCount-1 do StringGrid3.Cells[0,i]:=IntToStr(i);
StringGrid3.Visible:=true;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
var i,j,m:integer;
s:real;
begin
case radiogroup1.ItemIndex of
0:begin
for i:= 1 to stringGrid1.ColCount-1 do
for j:= 1 to stringGrid1.ColCount-1 do
StringGrid3.Cells[i,j]:=FloatToStr( StrTofloat(StringGrid1.Cells[i,j])+
StrTofloat(StringGrid2.Cells[i,j]));
end;
1:begin
for i:= 1 to stringGrid1.ColCount-1 do
for j:= 1 to stringGrid1.ColCount-1 do
StringGrid3.Cells[i,j]:=FloatToStr( StrTofloat(StringGrid1.Cells[i,j])-
StrTofloat(StringGrid2.Cells[i,j]));
end;
2:begin
for j:= 1 to stringGrid1.ColCount-1 do begin
for i:= 1 to stringGrid1.ColCount-1 do
begin
s:=0;
for m:= 1 to stringGrid1.ColCount-1 do begin
s:=s+ StrTofloat(StringGrid1.Cells[m,j])*
StrTofloat(StringGrid2.Cells[i,m]);
end;
StringGrid3.Cells[i,j]:=FloatToStr(s);
end;
end;
end;
end;
end;end.
Logging in, please wait...
0 General Document comments
0 Sentence and Paragraph comments
0 Image and Video comments
New Conversation
General Document Comments 0
New Conversation
Hide Thread Detail
New Conversation