生成 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