Log in

View Full Version : Array dan Matrix, Error....


SinggahDapur
20th November 2011, 01:11 PM
agan-agan..tolongin dong..

sy buat program perkalian matrix pakai array...di delphi nih

tp error..katanya read memory 0x00000



salahnya dimana ya...




Code:

procedure TForm1.btn1Click(Sender: TObject);
var dim : Integer;
begin
dim := StrToInt(Edit1.Text);
StringGrid1.ColCount := dim;
StringGrid1.RowCount := dim;
StringGrid3.ColCount := dim;
StringGrid3.RowCount := dim;
end;


procedure TForm1.Button1Click(Sender: TObject);
var x,y,w : byte;

dim : Integer;
arr1 : array of array of double;
arr2 : array of array of double;
arrhasil : array of array of double;

begin
dim := StrToInt(Edit1.Text);
SetLength(arr1,dim);
SetLength(arr2,dim);
SetLength(arrhasil,dim);

for y := 0 to dim do
begin
for x := 0 to dim do
begin
arr1[y,x] := StrToFloat(StringGrid1.Cells[y,x]);
arr2[y,x] := StrToFloat(StringGrid1.Cells[y,x]);
end;
end;

for w := 0 to dim do
begin
for y := 0 to dim do
begin
arrhasil[w,y] := 0;
for x := 0 to dim do
begin
arrhasil[w,y] := arrhasil[w,y] + arr1[x,w]*arr2[y,x];
end;
end;
end;

for y := 0 to dim do
begin
for x := 0 to dim do
begin
stringGrid3.Cells[x,y] := FloatToStr(arrhasil[y,x]);
end;
end;

end;



</div>