Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created December 19, 2015 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcha/55a627ffcdacd8cdba52 to your computer and use it in GitHub Desktop.
Save tomcha/55a627ffcdacd8cdba52 to your computer and use it in GitHub Desktop.
ouyou5
#!/usr/bin/env perl
use strict;
use warnings;
my @foods;
print "時間電卓です。時間と分を別々に入力して下さい。終わる時は、ENDを入力して下さい。\n";
my $total_hour = 0;
my $total_minutes = 0;
for (;;){
print "'時間'入力して下さい>";
my $h = <STDIN>;
chomp $h;
last if $h eq 'END';
$total_hour += $h;
print "'分'入力して下さい>";
my $m = <STDIN>;
chomp $m;
last if $m eq 'END';
$total_minutes += $m;
}
for (;$total_minutes >= 60; $total_minutes -= 60){
$total_hour++;
}
print "\n合計は$total_hour時間$total_minutes分です。\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment