home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / turbo_part1.lha / modula / examples / src / Lottery.mod < prev    next >
Encoding:
Text File  |  1995-01-06  |  814 b   |  33 lines

  1. (*   For those of us who dont belive in our own luck,                  *)
  2. (*   this program generates six unique random numbers between 1..49 for the   *)
  3. (*   british national lottery coupons.                          *)
  4.  
  5. MODULE Lottery ;
  6.  
  7. IMPORT
  8.   RN := RandomNumbers, InOut, Intuition ;
  9.  
  10. VAR
  11.   x , y : [0..05] ;
  12.   rnd   : [0..49] ;
  13.   list  : ARRAY [0..5] OF INTEGER ;
  14.   again : BOOLEAN ;
  15.  
  16. BEGIN
  17.   list := [0,0,0,0,0,0] ;
  18.   RN.SetSeed( Intuition.IntuitionBase^.Micros ) ;
  19.   FOR x := 0 TO 5 DO
  20.     LOOP
  21.       again := FALSE ;
  22.       rnd := TRUNC( RN.Uniform()*50.0 ) ;
  23.       FOR y := 0 TO 5 DO
  24.         (* Check for duplicates. 0's already in list so wont get chosen *)
  25.         IF list[y] = rnd THEN again := TRUE END
  26.       END ;
  27.       IF ~again THEN EXIT END
  28.     END ;
  29.     list[x] := rnd ;
  30.     InOut.WriteInt( rnd, 4 )
  31.   END
  32. END Lottery.
  33.