Hi!
i need to generate a pair of random numbers between 0 to 100
e.g. 0 - 2, 5 - 54, 98 - 100
there is two conditions, (1) the same number is not used as a pair e.g. 1-1, 2-2
(2) the same pair of number is not repeated and that would include 1-2, 2-1
the first condition is pretty easy, just that i could not find any way to account for the second?
for ($x=1 ; $x < 10; $x++)
{
&rand_num;
}
sub rand_num
{
my $range = 100;
$i = int(rand($range));
$j = int(rand($range));
if ($i==$j)
{
&rand_num;
}
i need to generate a pair of random numbers between 0 to 100
e.g. 0 - 2, 5 - 54, 98 - 100
there is two conditions, (1) the same number is not used as a pair e.g. 1-1, 2-2
(2) the same pair of number is not repeated and that would include 1-2, 2-1
the first condition is pretty easy, just that i could not find any way to account for the second?
for ($x=1 ; $x < 10; $x++)
{
&rand_num;
}
sub rand_num
{
my $range = 100;
$i = int(rand($range));
$j = int(rand($range));
if ($i==$j)
{
&rand_num;
}