delphi将一维数组读入文件 大虾进
procedureTForm1.Button1Click(Sender:TObject);varps:arrayoftpoint;beginSetLength(ps,6)...
procedure TForm1.Button1Click(Sender: TObject);
var
ps:array of tpoint;
begin
SetLength(ps, 6);
ps[0].X :=50;
ps[0].Y :=50;
ps[1].X :=100;
ps[1].Y :=50;
ps[2].X :=125;
ps[2].Y :=75;
ps[3].X :=100;
ps[3].Y :=100;
ps[4].X :=50;
ps[4].Y :=100;
ps[5].X :=25;
ps[5].Y :=75;
end;
如何将上述一维数组读进文件
写入 展开
var
ps:array of tpoint;
begin
SetLength(ps, 6);
ps[0].X :=50;
ps[0].Y :=50;
ps[1].X :=100;
ps[1].Y :=50;
ps[2].X :=125;
ps[2].Y :=75;
ps[3].X :=100;
ps[3].Y :=100;
ps[4].X :=50;
ps[4].Y :=100;
ps[5].X :=25;
ps[5].Y :=75;
end;
如何将上述一维数组读进文件
写入 展开
2个回答
展开全部
var
ps:array of tpoint;
I: Integer;
alist: TStringList;
begin
SetLength(ps, 6);
ps[0].X :=50;
ps[0].Y :=50;
ps[1].X :=100;
ps[1].Y :=50;
ps[2].X :=125;
ps[2].Y :=75;
ps[3].X :=100;
ps[3].Y :=100;
ps[4].X :=50;
ps[4].Y :=100;
ps[5].X :=25;
ps[5].Y :=75;
alist := TStringList.Create;
try
For I := Low(ps) To High(ps) Do
Begin
alist.Add(Format('%d,%d',[ps[I].X, ps[I].Y ]));
End;
alist.SaveToFile('C:\ps.log');
finally
alist.Clear;
alist.Free;
end;
ps:array of tpoint;
I: Integer;
alist: TStringList;
begin
SetLength(ps, 6);
ps[0].X :=50;
ps[0].Y :=50;
ps[1].X :=100;
ps[1].Y :=50;
ps[2].X :=125;
ps[2].Y :=75;
ps[3].X :=100;
ps[3].Y :=100;
ps[4].X :=50;
ps[4].Y :=100;
ps[5].X :=25;
ps[5].Y :=75;
alist := TStringList.Create;
try
For I := Low(ps) To High(ps) Do
Begin
alist.Add(Format('%d,%d',[ps[I].X, ps[I].Y ]));
End;
alist.SaveToFile('C:\ps.log');
finally
alist.Clear;
alist.Free;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询