生成 0 到 9 之间的随机整数
将随机浮点数转换为 int。
输入:
my $range = 10;
# create random integer as low as 0 and as high as 9
my $random = int(rand($range)); # max value is up to but not equal to $range
print $random . "\n";
输出:
一个随机整数,如……
0
将随机浮点数转换为 int。
输入:
my $range = 10;
# create random integer as low as 0 and as high as 9
my $random = int(rand($range)); # max value is up to but not equal to $range
print $random . "\n";
输出:
一个随机整数,如……
0