perl有一个自带的随机打乱数组的库,使用方法如下:

use List::Util;

@array = List::Util::shuffle @array;

 

举一个例子:

#! /usr/bin/perl
use List::Util;

my @a=(1..10);
@a=List::Util::shuffle @a;

foreach my $num(@a){
    print "$num\n";
}

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2022-01-27
  • 2021-08-21
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2022-03-03
  • 2021-12-20
  • 2021-12-19
  • 2022-12-23
相关资源
相似解决方案