我有一个移动数组值位置的程序位置 1 的字符串应该取位置 2 的字符串的值,位置 2 的字符串应该取位置 1 的字符串的值(和等等)例如。
开头的数组:
Pos Value
1 A
2 B
3 C
最后的数组(它应该成为什么):
Pos Value
1 B
2 C
3 A
这是代码:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
arrRotor = array [1 .. 10] of string;
TForm2 = class(TForm)
Button1: TButton;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure ArrayShiftRowUp(arrArrayShift: arrRotor );
end;
var
Form2: TForm2;
j, i : integer;
temps:string;
arrTest: arrRotor;
implementation
{$R *.dfm}
procedure TForm2.ArrayShiftRowUp(arrArrayShift: arrRotor );
begin
for i := 1 to Length(arrArrayShift)-1 do
begin
tempS := arrArrayShift[i];
arrArrayShift[i] := arrArrayShift[i + 1];
arrArrayShift[i + 1] := tempS;
RichEdit1.Lines.Add(arrArrayShift[i]);
end;
RichEdit1.Lines.Add(arrArrayShift[10]);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
for i := 1 to 10 do
begin
arrTest[i]:=Chr(64+i);
end;
for i := 1 to 10 do
begin
RichEdit1.Lines.Add(arrTest[i]);
end;
ArrayShiftRowUp(arrTest);
for i := 1 to 10 do
begin
RichEdit1.Lines.Add(arrTest[i]);
end;
end;
end.
但由于某种原因,实际数组没有改变。数组参数正在发生变化(正如富编辑中的显示所示),但由于某种原因,arrTest 没有变化。
问题是什么?