var
Source: TStringList;
Dest: array[0..99] of Integer;
Index, RandIndex: Integer;
begin
// 초기화
Randomize;
Source := TStringList.Create;
for Index := 0 to 99 do
Source.AddObject('', TObject(Index));
// 랜덤하게 배열에 저장하기
for Index := 99 downto 0 do
begin
RandIndex := Random(Index + 1);
Dest[Index] := Integer(Source.Objects[RandIndex]);
Source.Delete(RandIndex);
end;
// ...
Source.Free;
// ListBox1에 보여주기
for Index := 0 to 99 do
ListBox1.Items.Add(IntToStr(Dest[Index]));
end;
아래와 같이 해보세요...
var
Source: TStringList;
Dest: array[0..99] of Integer;
Index, RandIndex: Integer;
begin
// 초기화
Randomize;
Source := TStringList.Create;
for Index := 0 to 99 do
Source.AddObject('', TObject(Index));
// 랜덤하게 배열에 저장하기
for Index := 99 downto 0 do
begin
RandIndex := Random(Index + 1);
Dest[Index] := Integer(Source.Objects[RandIndex]);
Source.Delete(RandIndex);
end;
// ...
Source.Free;
// ListBox1에 보여주기
for Index := 0 to 99 do
ListBox1.Items.Add(IntToStr(Dest[Index]));
end;
^^ 항상 즐코하세요...