Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use List::Util qw(max);
- open my $fin, '<', 'input.txt' or die;
- open my $fout, '>', 'output.txt' or die;
- my $col = <$fin> * 6 + 1;
- my @line = split / / , <$fin>;
- my $row = max(@line) + 3;
- for(my $i = 0; $i < $row; $i++) {
- for (my $j = 0; $j < $col; $j++) {
- if ($i == 0 || $i == $row - 1) {
- if ($i == $row - 1 && $j > 0) {
- print $fout '+---+-';
- $j += 5;
- next;
- }
- $i == $row - 1 ? print $fout '-' : print $fout '.';
- next;
- }
- for(my $k = 0; $k < scalar(@line); $k++) {
- if ($j == $k * 6 + 1 && $row - $line[$k] - 2 == $i) {
- print $fout '+---+';
- $j += 5;
- }
- elsif ($j == $k * 6 + 1 && $row - $line[$k] - 2 < $i) {
- print $fout '|###|';
- $j += 5;
- }
- }
- if($j < $col) {
- print $fout '.';
- }
- }
- print $fout "\n";
- }
- close $fin or die;
- close $fout or die;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement