Jump to content

Need some help with random numbers


Nuffilein805
 Share

Recommended Posts

Hi there,

I could use some help on a little prog of mine.

I just want the programm to spit out a random number but: the user using this prog wants to give a couple of numbers from which this one is chosen. i though about something like this:

dim $c[4]
$a = inputbox ("numbers", "seperate by ','")
$b = stringsplit ($a, ",")
for $e = 1 to 3 step 1
Do
$c[$e] = random (1, 100,1)
$d = 0
Do 
$d = $d + 1
until $d = $b[0] or $c[$e] = $b[$d]
until $c[$e] = $b[$d]
Next
msgbox (0, "", $c[1] & "." & $c[2] & "." & $c[3])

I'm so far at the moment but how can I manage that I have no double numbers?

I'm getting really sick because of this.

Link to comment
Share on other sites

#include <Array.au3>
Dim $avArray[1]

For $i = 1 to 19;for testing
_ArrayAdd( $avArray, $i)
$avArray[$i] = $i
next

$min = _ArrayMin ( $avArray, 1 ) + 1
$max = _ArrayMax ( $avArray, 1 )

$rnd = Random ( $min , $max , 1 )
;MsgBox(64, "Testing", $rnd)

_ArrayDelete ( $avArray, $rnd )
_ArraySort ( $avArray)
_ArrayDisplay( $avArray, "New Array" )

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...