aArr : array[0..9] of Integer = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);怎么把数组aArr的第3位到到第6位复制到另外一个数组里面去?
不用for可以做到吗,有什么函数可供使用?
不用for可以做到吗,有什么函数可供使用?
解决方案 »
- RAD Studio XE2全球发布会 深圳会议 去参会的朋友多吗? 2011年10月14日(周五) 深圳威尼斯皇冠假日酒店
- ado 赋值 的问题
- 如何提取应用程序对话框里显示的数据?
- 想保存CSDN的文档,却不行啊!!!
- TQUERY1.APPEND增加不了空记录,求救!!!
- delphi7用ClientDataSet联接interbase7.1,出现“Operation not applicable”错误,delphi7不支持吗?
- ControlBar的问题
- Delphi循环插入
- 请各位大侠讨论Delphi是否支持红外的问题?
- 有没有关于dilphi好的书请介绍几本了。
- 动态创建新窗体的问题
- 请教,查询数据到dbgrid显示,如何将值1显示为男,2显示女?
A1,A2 : integer;
A1 := aArr[2];
A2 := aArr[5];
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
aArr: array[0..9] of Integer = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
aArr2: array[0..3] of Integer;
begin
Move(aArr[3], aArr2[0], SizeOf(Integer)*4);
end;end.
楼主是否这种想法:var
aArr: array[0..9] of Integer = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
...
procedure CopyArr(var ATargetArr: array of Integer; ASourceArr: array of Integer);
var
L: Integer;
begin
L := High(ASourceArr);
if High(ATargetArr) < L then
raise Exception.Create('size out!'); L := L + 1;
Move(ASourceArr[0], ATargetArr[0], SizeOf(Integer) * L);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
tmpArr: array of Integer;
begin
SetLength(tmpArr, 2);
CopyArr(tmpArr, [aArr[3-1], aArr[6-1]]); ShowMessage(IntToStr(tmpArr[0]) +', '+ IntToStr(tmpArr[1]));
end;
在Delphi中有这么麻烦吗?对Delphi真是头痛,有能给写个简便易懂的。
type
TaArr: array of Integer;
var
aArr: array[0..9] of Integer = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
tmpArr: TaArr;
tmpLoop: Integer;
begin
SetLength(tmpArr,4);
for tmpLoop := 0 to 3 do
tmpArr[tmpLoop] := aArr[tmpLoop + 3];
end;大家为何视简单而不做呢?
用for也不是很复杂呀!!