多维数组的传递问题 ( 积分: 100 )

  • 主题发起人 主题发起人 trimtrim
  • 开始时间 开始时间
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);
 
这样写: for j :=low(Grid) to high(Grid) do begin

如:
for i :=low(Grid) to high(Grid) do begin
for j :=low(Grid) to high(Grid) do begin
...
 
谢谢了,采用你的方法后问题解决了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
698
import
I
后退
顶部