T
trimtrim
Unregistered / Unconfirmed
GUEST, unregistred user!
数据通过多维动态数组传递,可是却传递不对,请告知原因,谢谢:
MTpoint = record
x,y :single;
end;
TGrid = array of array of MTPoint;
Procedure CreateGrid(DisPerGrid:Tpoint
Grid:TGrid);
var
i,j :integer;
Gridfile:Textfile;
begin
for i :=low(Grid) to high(Grid) do begin
for j :=low(Grid[0]) to high(Grid[0]) do begin
Grid[j].x := i*DisPerGrid.X ;
Grid[j].y := j*DisPerGrid.Y ;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
DisPerGrid,GNumber :Tpoint;
grid :Tgrid;
i,j :integer;
GridFile:textfile;
begin
DisPerGrid.X :=100;
DisPerGrid.Y :=100;
Gnumber.X :=410;
Gnumber.Y :=360;
Setlength(grid,GNumber.X,GNumber.y);
createGrid(Dispergrid,Grid);////Grid 写出的数据和在函数中写出的数据不一样
assignfile(Gridfile,'coor.dat');
rewrite(Gridfile);
for i :=0 to Gnumber.Y-1 do begin
for j:=0 to GNumber.X -1 do begin
writeln (Gridfile,format('%d %10.4f %10.4f',[i*Gnumber.x+j,Grid[j].x,Grid[j].y]));
end;
end;
closefile(Gridfile);
MTpoint = record
x,y :single;
end;
TGrid = array of array of MTPoint;
Procedure CreateGrid(DisPerGrid:Tpoint
Grid:TGrid);
var
i,j :integer;
Gridfile:Textfile;
begin
for i :=low(Grid) to high(Grid) do begin
for j :=low(Grid[0]) to high(Grid[0]) do begin
Grid[j].x := i*DisPerGrid.X ;
Grid[j].y := j*DisPerGrid.Y ;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
DisPerGrid,GNumber :Tpoint;
grid :Tgrid;
i,j :integer;
GridFile:textfile;
begin
DisPerGrid.X :=100;
DisPerGrid.Y :=100;
Gnumber.X :=410;
Gnumber.Y :=360;
Setlength(grid,GNumber.X,GNumber.y);
createGrid(Dispergrid,Grid);////Grid 写出的数据和在函数中写出的数据不一样
assignfile(Gridfile,'coor.dat');
rewrite(Gridfile);
for i :=0 to Gnumber.Y-1 do begin
for j:=0 to GNumber.X -1 do begin
writeln (Gridfile,format('%d %10.4f %10.4f',[i*Gnumber.x+j,Grid[j].x,Grid[j].y]));
end;
end;
closefile(Gridfile);