
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
Label1: TLabel;
StringGrid1: TStringGrid;
Button1: TButton;
Label2: TLabel;
Edit1: TEdit;
Button2: TButton;
Button3: TButton;
BitBtn1: TBitBtn;
StringGrid2: TStringGrid;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ordo:integer;
A,L:array[1..100,1..100]of real;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j,k:integer; m:real;
begin
groupbox3.Visible:=true;
if radiogroup1.ItemIndex=0 then
begin
for i:=1 to ordo do
for j:=1 to ordo do
begin
A[i,j]:=strtofloat(stringgrid1.Cells[j,i]);
if i<>j then
L[i,j]:=0
else
L[i,j]:=1;
end;
for k:=1 to ordo-1 do
for i:=k+1 to ordo do
begin
m:=A[i,k]/A[k,k];
L[i,k]:=m;
for j:=k to ordo do
begin
A[i,j]:=A[i,j]-m*A[k,j];
end;
end;
stringgrid2.RowCount:=ordo+1;
stringgrid2.ColCount:=ordo+1;
stringgrid2.Cells[0,0]:='i,j';
for i:=1 to ordo do
begin
stringgrid2.Cells[0,i]:=inttostr(i);
stringgrid2.Cells[i,0]:=inttostr(i);
end;
for i:=1 to ordo do
for j:=1 to ordo do
stringgrid2.Cells[j,i]:=copy(floattostr(L[i,j]),1,5);
end
else if radiogroup1.ItemIndex=1 then
begin
for i:=1 to ordo do
for j:=1 to ordo do
A[i,j]:=strtofloat(stringgrid1.Cells[j,i]);
for k:=1 to ordo do
for i:=k+1 to ordo do
begin
m:=A[i,k]/A[k,k];
for j:=k to ordo do
begin
A[i,j]:=A[i,j]-m*A[k,j];
end;
end;
stringgrid2.RowCount:=ordo+1;
stringgrid2.ColCount:=ordo+1;
stringgrid2.Cells[0,0]:='i,j';
for i:=1 to ordo do
begin
stringgrid2.Cells[0,i]:=inttostr(i);
stringgrid2.Cells[i,0]:=inttostr(i);
end;
for i:=1 to ordo do
for j:=1 to ordo do
stringgrid2.Cells[j,i]:=copy(floattostr(A[i,j]),1,5);
end
else
begin
application.MessageBox('Tentukan jenis Matrix yang akan dipakai!','Message',MB_OK +MB_ICONWARNING);
groupbox3.Visible:=false;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
groupbox2.Visible:=true;
stringgrid1.Visible:=true;
ordo:=strtoint(edit1.Text);
stringgrid1.ColCount:=ordo+1;
stringgrid1.RowCount:=ordo+1;
stringgrid1.Cells[0,0]:='i/j';
for i:=1 to ordo do
begin
stringgrid1.Cells[0,i]:=inttostr(i);
stringgrid1.Cells[i,0]:=inttostr(i);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i:integer;
begin
for i:=1 to ordo do
stringgrid1.Rows[i].Clear;
edit1.Clear;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
groupbox2.Visible:=false;
groupbox3.Visible:=false;
end;
end.
TForm1 = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
Label1: TLabel;
StringGrid1: TStringGrid;
Button1: TButton;
Label2: TLabel;
Edit1: TEdit;
Button2: TButton;
Button3: TButton;
BitBtn1: TBitBtn;
StringGrid2: TStringGrid;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ordo:integer;
A,L:array[1..100,1..100]of real;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j,k:integer; m:real;
begin
groupbox3.Visible:=true;
if radiogroup1.ItemIndex=0 then
begin
for i:=1 to ordo do
for j:=1 to ordo do
begin
A[i,j]:=strtofloat(stringgrid1.Cells[j,i]);
if i<>j then
L[i,j]:=0
else
L[i,j]:=1;
end;
for k:=1 to ordo-1 do
for i:=k+1 to ordo do
begin
m:=A[i,k]/A[k,k];
L[i,k]:=m;
for j:=k to ordo do
begin
A[i,j]:=A[i,j]-m*A[k,j];
end;
end;
stringgrid2.RowCount:=ordo+1;
stringgrid2.ColCount:=ordo+1;
stringgrid2.Cells[0,0]:='i,j';
for i:=1 to ordo do
begin
stringgrid2.Cells[0,i]:=inttostr(i);
stringgrid2.Cells[i,0]:=inttostr(i);
end;
for i:=1 to ordo do
for j:=1 to ordo do
stringgrid2.Cells[j,i]:=copy(floattostr(L[i,j]),1,5);
end
else if radiogroup1.ItemIndex=1 then
begin
for i:=1 to ordo do
for j:=1 to ordo do
A[i,j]:=strtofloat(stringgrid1.Cells[j,i]);
for k:=1 to ordo do
for i:=k+1 to ordo do
begin
m:=A[i,k]/A[k,k];
for j:=k to ordo do
begin
A[i,j]:=A[i,j]-m*A[k,j];
end;
end;
stringgrid2.RowCount:=ordo+1;
stringgrid2.ColCount:=ordo+1;
stringgrid2.Cells[0,0]:='i,j';
for i:=1 to ordo do
begin
stringgrid2.Cells[0,i]:=inttostr(i);
stringgrid2.Cells[i,0]:=inttostr(i);
end;
for i:=1 to ordo do
for j:=1 to ordo do
stringgrid2.Cells[j,i]:=copy(floattostr(A[i,j]),1,5);
end
else
begin
application.MessageBox('Tentukan jenis Matrix yang akan dipakai!','Message',MB_OK +MB_ICONWARNING);
groupbox3.Visible:=false;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
groupbox2.Visible:=true;
stringgrid1.Visible:=true;
ordo:=strtoint(edit1.Text);
stringgrid1.ColCount:=ordo+1;
stringgrid1.RowCount:=ordo+1;
stringgrid1.Cells[0,0]:='i/j';
for i:=1 to ordo do
begin
stringgrid1.Cells[0,i]:=inttostr(i);
stringgrid1.Cells[i,0]:=inttostr(i);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i:integer;
begin
for i:=1 to ordo do
stringgrid1.Rows[i].Clear;
edit1.Clear;
groupbox2.Visible:=false;
groupbox3.Visible:=false;end;
procedure TForm1.FormCreate(Sender: TObject);
begin
groupbox2.Visible:=false;
groupbox3.Visible:=false;
end;
end.
5 comments:
henk,kpn2 klo ngasih tgs dblog.. peke design interfacenya yg asli dunk..
klo cm listing programnya aj, qt ttep gbs bkinnya,,
okeh,,
sofware apaan tuch, henk???
Thanks buat masukannya....
@Deddy, ini pake software Borland Delphi 7
Mau naNya nich! giMana carax ngisi data dlm tabel stringgrid secara laNgsung? udh brapa kLi gw coba, tpi kok ga bisa2 jga yach?
Post a Comment
Kalau berkenan, dikoment donk untuk menjadi masukan buad Admin