Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created August 20, 2014 06:57
Show Gist options
  • Save Code-Hex/4733f8538a7edece957d to your computer and use it in GitHub Desktop.
Save Code-Hex/4733f8538a7edece957d to your computer and use it in GitHub Desktop.
Perl 練習問題 回答よりも優れてたと思うw
#! /usr/bin/perl
use strict;
use warnings;
my $n = "\n";
print "Please input number 1~7" . $n;
my @lines = <STDIN>;
chomp @lines;
print $n;
my @array = qw/fred betty barney dino wilma pebbles bamm-bamm/;
my @box;
print "input data: " . $n;
my $i = 0;
for (@lines){
$box[$i] = $array[$_-1];
$i++;
}
print "$_ " foreach (sort @box);
@Code-Hex
Copy link
Author

問題は "文字列のリストを(1行に1個ずつ)入力の終わりまで読み込んで、読み込んだ文字列をASCIIコード順に表示せよ" ってやつ。
工夫したのは数字で名前を呼び出すって所だけだけどww

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment