brpleshek@miavx2.ham.muohio.edu (02/20/91)
i'm working on translating on of my programs from Basic to Pascal, but i'm having trouble creating a random number generation routine. Any of them out there? Any help would be appreciated. thanx brian brpleshek@miavx0.bitnet brpleshek@miavx9.bitnet
mwizard@eecs.cs.pdx.edu (Craig Nelson) (02/20/91)
brpleshek@miavx2.ham.muohio.edu writes: >i'm working on translating on of my programs from Basic to Pascal, but i'm >having trouble creating a random number generation routine. Any of them out >there? Any help would be appreciated. >thanx >brian Brian, give us a clue as what version of Pascal (if available) that your using. Makes for better answers. If your in Turbo the answer is even simpler. Craig (mwizard@eecs.ee.pdx.edu)
kamal@wpi.WPI.EDU (Kamal Z Zamli) (02/20/91)
In article <1991Feb19.232457.408@miavx2.ham.muohio.edu> brpleshek@miavx2.ham.muohio.edu writes: >i'm working on translating on of my programs from Basic to Pascal, but i'm >having trouble creating a random number generation routine. Any of them out >there? Any help would be appreciated. > >thanx Try the following codes: const Max = 100; type List = array [1..Max] integer; var Data:List; procedure RandomNumber (var Data:List); var i:integer; begin Randomize; (* initialize random number generator *) for i:=1 to Max do begin List[i]:=Rnd (100); (* generate a positive only random number between 1 to 100 *) end; end; (* RandomNumber *) begin RandomNumber(Data); end. Sometimes you might want to vary your random number generator such that it will produce a negative number as part of the number. in order to do that type the follwin code: procedure RandomNumber (Vat Data:List); var i:integer; Temp:integer; begin Randomize; for i:=1 to Max do begin Temp:=Rnd(100); List[i]:=Temp - 50; (* get some negative number too *) end; end;