how to get the value from the array randomly
David McFarlane
mcfarla9 at msu.edu
Fri Nov 8 14:54:26 UTC 2013
I will just add that you can find documentation for the random()
function in the E-Basic Help facility.
-- David McFarlane
At 11/7/2013 10:21 PM Thursday, gorgeous yayuan geng wrote:
>Dear Sihua,
>
>c = random(a(1), a(4)) . I think this code is the reason. You
>originally want to get a random number from 6,3,7,2,which is in the
>array a, but your code is to select a value randomly from 6 to 2,
>which means you get a random value from 2,3,4,5,6. and I wonder if
>you can successfully complie the code since random function needs
>the first parameter as min, the second parameter as max.
>so I would recommend that you get a random value from 1,2,3,4 .I'd
>better give you codes:
>t=random(1,4)
>c=a(t);
>s=random(1,3)
>d=b(s)
>
>
>
>
>2013/11/8 sihua xu <<mailto:xusihua80 at gmail.com>xusihua80 at gmail.com>
>Hello everyone
>
> I know how to define the array with the help of David and sally,
> and I get the value randomly according to way that they told me,
> but actually, I found the program do not get the value of the
> array randomly and i do not know the reason.
>I want to achieve the purpose of the following
> to get one value from each array and decide to end or continue the
> program by comparing the size of the value from the two arrays. the
> script example just as follows
>dim a(1 to 4) as integer
>dim b (1 to 3) as integer
>dim c as integer
>dim d as integer
>dim randompik as integer
>a(1) = 6
>a(2) = 3
>a(3) = 7
>a(4) = 2
>b(1) = 2
>b(2)= 6
>b(3) = 4
>c = random(a(1), a(4))
>d = random(b(1), b(3))
>if c>d then
> randompik = 1
>else randompik =2
>end if
>
>I would be grateful if anybody could help me to find the reason why
>it can not achieve my purpose and modify that
>
>
>Sihua Xu
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/527cfb28.893d320a.5ec9.1411SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/groups/opt_out.
More information about the Eprime
mailing list