Use 1 to 100 as the fixed interval to generate two numbers. Do not use recursion. Use 1 to 100 as the fixed interval.
Generate two numbers without Recursion
Reply content:
Fixed range from 1 to 100
Generate two numbers without Recursion
Specified red by @ finallygo
$range = range(1,100);
1,
shuffle($range);$first = $range[0];$second = $range[1];
2,
list($first, $second) = array_rand($range,2);//array_rand return index which starts from 0$first++; $second++;
Php syntax does not understand, but it can be converted into two random numbers, two subtract as the first number, and the sum as the second number
The main idea is to use php (the following code must be supported in php 5.3 or later)
1
push($i); 5 } 6 $fetch_size = 2; 7 for($j=0;$j<$fetch_size;$j++) { 8 $index = rand() % count($a); 9 echo 'rand(' . $j . '):' . $a->offsetGet($index) . "\n"; $a->offsetUnset($index); 10 } 11 ?>
Random rnd = new Random();int a, b;a = rnd.Next(100) + 1;b = rnd.Next(99) + 1;if (a == b) b = 100;Console.WriteLine("{0} {1}", a, b);
Random rnd = new Random();var arr = Enumerable.Range(1, 100).OrderBy(t => rnd.Next()).Take(2).ToArray();Console.WriteLine("{0} {1}", arr[0], arr[1]);
var a, b; a = Math.random(); do{ b = Math.random(); } while(b == a)
Any series can be called "random series". The difference is that the probability distribution is different. Since the subject does not mention the distribution, I can only assume that the subject does not care:
$a=1; $b=2;
It fully meets the subject requirements.
It's so clever to go upstairs. Let me do it.
cat /dev/random
Http://zh.wikipedia.org/zh-cn//dev/random