Vous êtes sur la page 1sur 4

procedure TForm1.

Button1Click(Sender: TObject);
var
i,j,k : integer;
data1 : array [1..10, 1..10] of integer;
data2 : array [1..10, 1..10] of integer;
hasil : array [1..10, 1..10] of integer;
begin
if RadioButton1.checked then
begin
if (edit1.Text = edit3.Text) and (edit2.Text = edit4.Text) then
begin
for i := 1 to strtoint(edit1.Text) do
begin
StringGrid1.Cells[0,i] := B + InttoStr(i);
StringGrid2.Cells[0,i] := B + InttoStr(i);
StringGrid3.Cells[0,i] := B + InttoStr(i);
for j:= 1 to strtoint(edit2.Text) do
begin
StringGrid1.Cells[i,0] := K + InttoStr(i);
StringGrid2.Cells[i,0] := K + InttoStr(i);
StringGrid3.Cells[i,0] := K + InttoStr(i);
StringGrid3.Cells[i,j] := ;
data1[i,j] := StrtoInt(StringGrid1.Cells[i,j]);
data2[i,j] := StrtoInt(StringGrid2.Cells[i,j]);
Hasil[i,j] := data1[i,j] + data2[i,j];
stringGrid3.RowCount := strtoint(edit1.Text)+1;
stringGrid3.ColCount := strtoint(edit2.Text)+1;
StringGrid3.Cells[i,j] := inttostr(Hasil[i,j]);
end;
end;
end
else
showmessage(Ukuran Matriks Tidak sama);
edit1.SetFocus;
end;
if RadioButton2.checked then
begin
if ((edit2.Text) = (edit3.Text)) then
begin
for i := 1 to StrtoInt(Edit1.Text) do
for j:= 1 to StrtoInt(Edit4.Text) do
begin
Hasil[i,j] := 0;
for k:= 1 to StrtoInt(Edit2.Text) do
begin
data1[i,k] := StrtoInt(StringGrid1.Cells[k,i]);
data2[k,j] := StrtoInt(StringGrid2.Cells[j,k]);
Hasil [i,j] := Hasil[i,j] + data1[i,k] * data2[k,j];
StringGrid3.RowCount := StrtoInt(edit1.Text) + 1;
StringGrid3.ColCount := StrtoInt(edit4.Text) + 1;
end;
StringGrid3.Cells[j,i] := inttostr(Hasil[i,j]);
end;
end
else
begin
showmessage(Ukuran Matriks Tidak Sesuai);
edit2.SetFocus;
end;
end;
if RadioButton3.checked then
begin
stringGrid3.RowCount := strtoint(edit2.Text)+1;
stringGrid3.ColCount := strtoint(edit1.Text)+1;
for i := 1 to strtoint(edit2.Text) do
begin
for j:= 1 to strtoint(edit1.Text) do
StringGrid3.Cells[j,i] := StringGrid1.Cells[i,j];
end;
end;
if RadioButton4.checked then
begin
stringGrid3.RowCount := strtoint(edit4.Text)+1;
stringGrid3.ColCount := strtoint(edit3.Text)+1;
for i := 1 to strtoint(edit4.Text) do
begin
for j:= 1 to strtoint(edit3.Text) do
StringGrid3.Cells[j,i] := StringGrid2.Cells[i,j];
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[1, 1] := 1';
StringGrid1.Cells[1, 2] := 0';
StringGrid1.Cells[1, 3] := 0';
StringGrid1.Cells[1, 4] := 0';
StringGrid1.Cells[1, 5] := 0';
StringGrid1.Cells[2, 1] := 0';
StringGrid1.Cells[2, 2] := 1';
StringGrid1.Cells[2, 3] := 0';
StringGrid1.Cells[2, 4] := 0';
StringGrid1.Cells[2, 5] := 0';
StringGrid1.Cells[3, 1] := 0';
StringGrid1.Cells[3, 2] := 0';
StringGrid1.Cells[3, 3] := 1';
StringGrid1.Cells[3, 4] := 0';
StringGrid1.Cells[3, 5] := 0';
StringGrid1.Cells[4, 1] := 0';
StringGrid1.Cells[4, 2] := 0';
StringGrid1.Cells[4, 3] := 0';
StringGrid1.Cells[4, 4] := 1';
StringGrid1.Cells[4, 5] := 0';
StringGrid1.Cells[5, 1] := 0';
StringGrid1.Cells[5, 2] := 0';
StringGrid1.Cells[5, 3] := 0';
StringGrid1.Cells[5, 4] := 0';
StringGrid1.Cells[5, 5] := 1';
StringGrid2.Cells[1, 1] := 5';
StringGrid2.Cells[1, 2] := 5';
StringGrid2.Cells[1, 3] := 5';
StringGrid2.Cells[1, 4] := 5';
StringGrid2.Cells[1, 5] := 5';
StringGrid2.Cells[2, 1] := 4';
StringGrid2.Cells[2, 2] := 4';
StringGrid2.Cells[2, 3] := 4';
StringGrid2.Cells[2, 4] := 4';
StringGrid2.Cells[2, 5] := 4';
StringGrid2.Cells[3, 1] := 3';
StringGrid2.Cells[3, 2] := 3';
StringGrid2.Cells[3, 3] := 3';
StringGrid2.Cells[3, 4] := 3';
StringGrid2.Cells[3, 5] := 3';
StringGrid2.Cells[4, 1] := 2';
StringGrid2.Cells[4, 2] := 2';
StringGrid2.Cells[4, 3] := 2';
StringGrid2.Cells[4, 4] := 2';
StringGrid2.Cells[4, 5] := 2';
StringGrid2.Cells[5, 1] := 1';
StringGrid2.Cells[5, 2] := 1';
StringGrid2.Cells[5, 3] := 1';
StringGrid2.Cells[5, 4] := 1';
StringGrid2.Cells[5, 5] := 1';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
GroupBox2.Caption := Hasil Penjumlahan Matrik A dan B ;
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
GroupBox2.Caption := Hasil Perkalian Matrik A dan B ;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
label3.Left := label3.Left 4;
if label3.Left <= -90 then
label3.Left := 270;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
stringGrid1.RowCount := strtoint(edit1.Text)+1;
if (strtoint(edit1.Text)) > 6 then
Begin
StringGrid1.DefaultRowHeight := 15;
StringGrid3.DefaultRowHeight := 15;
end;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
stringGrid1.ColCount := strtoint(edit2.Text)+1;
if (strtoint(edit2.Text)) > 6 then
begin
StringGrid1.DefaultColWidth := 30;
StringGrid3.DefaultColWidth := 30;
end;
end;
procedure TForm1.Edit3Change(Sender: TObject);
begin
stringGrid2.RowCount := strtoint(edit3.Text)+1;
if (strtoint(edit3.Text)) > 6 then
Begin
StringGrid2.DefaultRowHeight := 15;
StringGrid3.DefaultRowHeight := 15;
end;
end;
procedure TForm1.Edit4Change(Sender: TObject);
begin
stringGrid2.ColCount := strtoint(edit4.Text)+1;
if (strtoint(edit4.Text)) > 6 then
begin
StringGrid2.DefaultColWidth := 30;
StringGrid3.DefaultColWidth := 30;
end;
end;
end.

Vous aimerez peut-être aussi