ShuDudu's Home was started in 2011, but the web data is lost, so now begin again, I would like to make some friends, I hope you like ShuDudu's home.
Current position: ShuDudu > Life >

Take several random numbers from a set of numbers

Saturday on December 12th, 2009Life

made a simple game of smashing golden eggs, which requires 5 golden eggs randomly selected from 50 golden eggs to choose from.

found a function that works well.
ASP/Visual Basic Code

  • & lt;% & nbsp; 
  • function showrnd (xonomy) & nbsp; 
  • if y
  • exit function & nbsp; 
  • end if & nbsp; 
  • redim n (x) & nbsp; 
  • dim i,q & nbsp; 
  • dim isok & nbsp; 
  • for i=1 to x & nbsp; 
  • Randomize & nbsp; 
  • n (I) = round ((ymur1) * & nbsp;Rnd) + 1roomnbspp; & nbsp;
  • isok=false & nbsp; 
  • do while not isok & nbsp; 
  • for q=1 to i & nbsp; 
  • if n (I) = n (QFEL) & nbsp;then & nbsp & nbsp;
  • n (I) = Int ((ymer1) * & nbsp;Rnd) + 1 & nbsp; 
  • isok=false & nbsp; 
  • exit for & nbsp; 
  • end if & nbsp; 
  • isok=true & nbsp; 
  • next & nbsp; 
  • loop & nbsp; 
  • & nbsp;   response.write n (I) & quot;
    "  & nbsp;
  • next & nbsp; 
  • end function & nbsp; 
  • & nbsp; 
  • '5 Random numbers generated between 1 and 50 & nbsp; 
  • call showrnd (5pm 50) & nbsp; 
  • % & gt;  
  • Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/life/Take-several-random-numbers-from-a-set-of-numbers.htm