var
S1,S2:TStringList;
I:Byte;
T:Word;
begin
Randomize;
S1:=TStringList.Create;
S2:=TStringList.Create;
try
for I:=1 to 100 do
S1.Append(IntToStr(I)); //把100个人放入S1中
for I:=1 to Round(S1.Count*0.6) do
begin
T:=Random(S1.Count-1);
S2.Append(S1.Strings[T]);
S1.Delete(T);
end;
//S2为选出的人
finally
FreeAndNil(S1);
FreeAndNil(S2);
end;
end;
代码已经给你了
button1.Click://加入队列:
begin
S1.Append(人名); //S1是全局的
end;
button2.Click:取出可以进入的人名:
var
S2:TStringList;
I:Byte;
T:Word;
begin
Randomize;
S2:=TStringList.Create;
try
for I:=1 to Round(S1.Count*0.6) do
begin
T:=Random(S1.Count-1);
S2.Append(S1.Strings[T]);
S1.Delete(T);
end;
//S2为选出的人
finally
FreeAndNil(S2);
end;
end;