Ver Mensaje Individual
  #16  
Antiguo 17-06-2008
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 24
maeyanes Va por buen camino
Hola...

Con un TStringList podría quedar más o menos así:

Código Delphi [-]
function Sortear: TStringList;
const
  NoGanadores = 300;
  NoParticipantes: 1505;

var
  I: Integer;
  Ganador: Integer;

begin
  Randomize;
  Result := TStringList.Create;
  Result.Sort := True;
  for I := 1 to NoGanadores do
  begin
    Ganador := RandomRange(1, NoParticipantes);
    if Result.Count = 0 then
      Result.Add(IntToStr(Ganador))
    else
    begin
      while Result.IndexOf(IntToStr(Ganador)) <> -1 do
        Ganador := RandomRange(1, NoParticipantes);
      Result.Add(IntToStr(Ganador))
    end
  end
end;

// Para usar la función:

var
  ListaGanadores: TStringList;

begin
  ListaGanadores := Sorteo;
  // Usas la lista
  ListaGanadores.Free
end;


Saludos...
Responder Con Cita