X
xiaoshun
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.GetPClick(Sender: TObject);
var
i,j,k: integer;
X: real;
begin
for i:=1 to N1do
for j:=1 to N1do
if V1.Cells[i,j]='' then
d1[i,j]:=0
else
begin
if uppercase(V1.Cells[i,j])='M' then
d1[i,j]:=1000000
else
d1[i,j]:=strtofloat(V1.Cells[i,j]);
end;
for i:=1 to N1do
begin
for j:=1 to N1do
begin
for k:=1 to N1do
begin
X:=D1[j,i]+D1[i,k];
if D1[j,k]<X then
temp1[j,k]:=D1[j,k]
else
temp1[j,k]:=X;
end;
end;
for j:=1 to n1do
for k:=1 to n1do
D1[j,k]:=temp1[j,k];
end;
if assigned(W1) then
W1.Free;
W1:=TStringGrid.Create(self);
W1.Parent:=GroupBox2;
W1.Top:=50;
W1.Left:=50;
W1.Height:=26*(N1+1);
W1.Width:=66*(N1+1);
W1.RowCount:=N1+1;
W1.ColCount:=N1+1;
W1.Align:=alClient;
W1.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,GoRangeSelect,goEditing];
for i:=1 to N1do
begin
W1.Cells[i,0]:=inttostr(i);
W1.cells[0,i]:=inttostr(i);
end;
for i:=1 to n1do
for j:=1 to n1do
begin
W1.Cells[i,j]:=Floattostr(D1[i,j]);
if temp1[i,j]<>1000000 then
W1.Cells[i,j]:=Floattostr(temp1[i,j])
else
W1.Cells[i,j]:='断路';
end;
end;
var
i,j,k: integer;
X: real;
begin
for i:=1 to N1do
for j:=1 to N1do
if V1.Cells[i,j]='' then
d1[i,j]:=0
else
begin
if uppercase(V1.Cells[i,j])='M' then
d1[i,j]:=1000000
else
d1[i,j]:=strtofloat(V1.Cells[i,j]);
end;
for i:=1 to N1do
begin
for j:=1 to N1do
begin
for k:=1 to N1do
begin
X:=D1[j,i]+D1[i,k];
if D1[j,k]<X then
temp1[j,k]:=D1[j,k]
else
temp1[j,k]:=X;
end;
end;
for j:=1 to n1do
for k:=1 to n1do
D1[j,k]:=temp1[j,k];
end;
if assigned(W1) then
W1.Free;
W1:=TStringGrid.Create(self);
W1.Parent:=GroupBox2;
W1.Top:=50;
W1.Left:=50;
W1.Height:=26*(N1+1);
W1.Width:=66*(N1+1);
W1.RowCount:=N1+1;
W1.ColCount:=N1+1;
W1.Align:=alClient;
W1.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,GoRangeSelect,goEditing];
for i:=1 to N1do
begin
W1.Cells[i,0]:=inttostr(i);
W1.cells[0,i]:=inttostr(i);
end;
for i:=1 to n1do
for j:=1 to n1do
begin
W1.Cells[i,j]:=Floattostr(D1[i,j]);
if temp1[i,j]<>1000000 then
W1.Cells[i,j]:=Floattostr(temp1[i,j])
else
W1.Cells[i,j]:='断路';
end;
end;