| | |
help with random numbers in pascal
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 3
Reputation:
Solved Threads: 0
I need a program that generates a nxn matrix with random numbers, but they're not completely random. They must be delimited in -20,0 < x < 20,0, for example, but all i searched for the Random functions in pascal says that it produce numbers in a interval starting in zero...so, i would like to know how do i generate random numbers in a -n < x < n interval.
If you don't want the same random numbers over and over again, at the very beginning of your program, call the randomize procedure.
As for the range, the problem is purely mathematical. If you have a list of seven numbers (0, 1, 2, 3, 4, 5, 6), what do you have to do to it to make it (-3, -2, -1, 0, 1, 2, 3)?
Hope this helps.
Delphi Syntax (Toggle Plain Text)
begin randomize; // init number generator from system clock ... end.
As for the range, the problem is purely mathematical. If you have a list of seven numbers (0, 1, 2, 3, 4, 5, 6), what do you have to do to it to make it (-3, -2, -1, 0, 1, 2, 3)?
Hope this helps.
Last edited by Duoas; Nov 10th, 2007 at 11:12 am.
![]() |
Similar Threads
- Compile time errors in C++ while generating random numbers (C++)
- C++ Random Numbers (C++)
- Trying to find a better way to generate random numbers in Dev Pascal (Pascal and Delphi)
- random numbers all different??? (C++)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Newbie needs help... ;)
- Next Thread: Returning arrays
Views: 1331 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi






