10-03-2003, 06:32 PM
random number
|
11-20-2003, 05:38 AM
Try the following function called "Uniform".
To use, code: "int r=Uniform(mn mx)" to return a value between numbers "mn" and "mx". Or you could just use the msvcrt function: rand ;;Uniform: L'Ecuyer Random number generator
11-20-2003, 02:18 PM
Wow this looks great but I thini I jacked up the paste.
The compiler didn"t like the commas in front of the lines so I took them out. However, this is what I got when I ran it for rand #s between 1 and 10 a bunch of times: 9 9 9 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 5 Any ideas why?
11-20-2003, 08:43 PM
I think you have older QM release. In QM 209 and later, commas in front of lines ar interpreted in same way as tabs. Function works ok.
11-20-2003, 08:58 PM
It says I have 2.0.9
does it copy/paste ok for you?
11-21-2003, 08:51 AM
Maybe it is beta. In any case, replace commas to tabs. Your result is like commas have been deleted.
What is wrong with copy/paste?
11-21-2003, 02:53 PM
WOW!!!!!
This worked great. I ran a quick 4,500 items list and everything was distributed within expected ranges... Thanks MU and thanks Gintaras for helping me figure out what was going on.
08-27-2007, 08:31 AM
Lets say I have a list of numerical numbers 0 to 100, and i want to make that list random without repeating any of the numbers what would be the best way to do this ?
08-27-2007, 06:39 PM
This is what i came up with if anyone has a better way of doing it please post it.
08-27-2007, 07:32 PM
[John_ : i edited your posting in the code part, to make the posting a little bit shorter]
i tried to make your code at least shorter with using the array example in Pointer , reference , array . but now i stumble over a problem. does not work. how do i remove and redim my array lines ?
08-27-2007, 07:37 PM
Quote:how do i remove and redim my array lines ? At low level. Use memmove. When calculating offset etc, multiply by sizeof(str).
08-27-2007, 07:41 PM
_pi Wrote:[John_ : i edited your posting in the code part, to make the posting a little bit shorter] Thats fine _pi I should have thought of that.
08-27-2007, 07:48 PM
08-27-2007, 07:57 PM
Gintaras Wrote:At low level. Use memmove. When calculating offset etc, multiply by sizeof(str). thats a bit to much for me today to investigate. can you please show how to use it in my code for John_ ?
08-27-2007, 08:04 PM
Don't use pointer-based arrays of str type, because it is too difficult, because you must not only move memory but also properly clear str elements. This is example:
;create array There are 7 lines of code to remove str element. Unless you put it in a function.
08-27-2007, 08:38 PM
Google for "randomize array" and you will find how it can be done. My version:
;create array Another version: ;create array
08-28-2007, 07:32 PM
What do you think of this ?
UPDATED int cnt;str ranlines linex lines= Member function str.RemoveLineN function# lineindex [nlines]
11-23-2007, 06:50 PM
is there any way to do this with the alphabet and only output random 5 letters?
11-23-2007, 07:50 PM
Member function str.Random. Create it using menu File New New Member Function.
function minlen maxlen [$charset]
11-23-2007, 11:29 PM
I dont understand what to do i tryed that but got nothing? is there any other functions or anything i need?
11-24-2007, 12:02 AM
Make sure you have this. Download the file off the link. is this the best way? (repeat code random number of times)
Taking on Quick Macros one day at a time
11-24-2007, 04:52 AM
yes i have that but i dont understand why its not working? can anyone plz explain what i ned and exactly the steps? thanks
11-24-2007, 01:52 PM
Create function Uniform, create member function str.Random, create a macro, put the EXAMPLE code int the macro, uncomment the code, run the macro to test how it works.
11-25-2007, 12:36 AM
OK, worked perfect except what do i need to change to make it only use A-Z Letters and any Numbers?
11-25-2007, 12:42 AM
Nevermind change it to 65-90 now its only letters but is there a way to do numbers and letters with out the stuff inbetween?
11-25-2007, 12:44 AM
For example i found this
Numbers (0-9) = 48-57 Letters (A-Z) = 65-90 I would like to include both sets but not whats inbetween? Can it be done?
11-25-2007, 10:34 AM
Updated. Now instead of minchar and maxchar use single string, like in examples.
11-26-2007, 01:16 AM
OK, Thanks Gint got it now works perfect
![]()
11-26-2007, 01:18 AM
Hmm, nevermind it didnt work? can you give another example of how to use anything A-Z and 0-9 ?? Thanks
|
« Next Oldest | Next Newest »
|
Users browsing this thread: 1 Guest(s)