我正在尝试使用计时器移动字符串,以便在我的 delphi 程序中为插入排序设置动画。任何人都可以提供任何建议吗?
procedure TForm1.Button1Click(Sender: TObject);
var
current_position, index, count : integer ;
temp : string ;
begin
current_position := 0 ; //start insertion sort
repeat
current_position := current_position + 1 ; //set up pointers
index := 0 ;
while index <= current_position do
begin
if word[index] > word[current_position] then
begin
temp:= word[current_position];
for count := current_position downto index + 1 do
begin
word[count]:= word[count-1]
end;
word[index]:= temp;
end;
index:= index + 1
end;
until current_position = 9 ;
for current_position := 0 to 9 do
StringGrid1.Cells[0,current_position]:= word[current_position];
end;