Fonction random en Delphi

alexyou Messages postés 14 Date d'inscription dimanche 4 juin 2006 Statut Membre Dernière intervention 17 octobre 2009 - 3 mars 2007 à 23:46
KR73 Messages postés 10 Date d'inscription jeudi 15 novembre 2007 Statut Membre Dernière intervention 3 juillet 2012 - 30 oct. 2008 à 14:34
tt le monde*salut;
j'aimerais bien que qlq 1 me dis comment on utilise la fonction   Random() par exemple un numéro de 1 à 100
mais que chaque fois on aura un num différent si elle sera ds un boucle par exemple
Merci d'avance
A voir également:

4 réponses

Utilisateur anonyme
4 mars 2007 à 00:05
Salut,

En  prenant la peine de chercher on rentre dans l'aide de delphi (touche F1), Random :

Unit

System

Category

random number routines

Delphi syntax:

function Random [ ( Range: Integer) ];

Description

In Delphi code, Random returns a random number within the range 0 <= X < Range. If Range is not specified, the result is a real-type random number within the range

0 <= X < 1.

To initialize the random number generator, add a single call Randomize or assign a value to the RandSeed variable before making any calls to Random.

Note:    Because the implementation of the Random function may change between compiler versions, we do not recommend using Random for encryption or other purposes that require reproducible sequences of pseudo-random numbers.

Puis en cliquant sur le label "Example", on obtient

var
   I: Integer;
 begin
   Randomize;
   for I := 1 to 50 do begin
     { Write to window at random locations }
     Canvas.TextOut(Random(Width), Random(Height), 'Boo!');
   end;
 end;

On est prié de chercher avant de poster
0