#! /usr/bin/perl
use warnings;
use strict;
my %dict = ('A'=>'E', 'E'=>'F', 'F'=>'H', 'H'=>'J', 'J'=>'K',
'K'=>'M', 'M'=>'P', 'P'=>'A', ' '=>'A');
my $max = 'P';
my $str_len = 4;
my @tmp;
for (my $i=0; $i<$str_len; $i++) { push(@tmp, ' ') }
sub up {
my($pos) = @_;
if (($tmp[$pos] eq $max) and ($pos < $str_len)) {
$tmp[$pos] = $dict{$tmp[$pos]};
$pos++; up($pos);
} else {
$tmp[$pos] = $dict{$tmp[$pos]};
return 0;
}
}
while (!(($tmp[0] eq $max) and ($tmp[1] eq $max)
and ($tmp[2] eq $max) and ($tmp[3] eq $max))) {
up(0);
for (@tmp) { print if ($_ ne ' ') }
print "\n";
}
没有评论:
发表评论