- 论坛徽章:
- 3
|
不懂perl
以下是不是你想要的?
- #!/bin/perl
- for (1..1000){
- open AOUT,">a$_.txt" || die "Can't open the file:$!";
- open BOUT,">b$-.txt" || die "Can't open the file:$!";
- open IN,"<data.txt" || die "Can't open the file:$!";
- while (<IN>) {
- /^\d+(\d+)\s+(\d+)/;
- #if($1==0){
- # next;
- #}
- do{
- my $temp=int((2/5+(rand($1)/$1)/5)*$1);
- my $temp2=int((2/5+(rand($2)/$2)/5)*$2);
- printf AOUT "%d %d %d\n",$_,$temp,$temp2;
- printf BOUT "%d %d %d\n",$_,$1-$temp,$2-$temp2;
- }
- until($temp/$temp2-(($1-$temp)/($2-$temp2)<0.03 || ($1-$temp)/($2-$temp2)-$temp/$temp2<0.03));
- close IN;
- close AOUT;
- close BOUT;
- }
- }
复制代码 |
|