Skip to content

Instantly share code, notes, and snippets.

@omas
Created December 13, 2014 03:07
Show Gist options
  • Select an option

  • Save omas/a8c66812857e2305beaf to your computer and use it in GitHub Desktop.

Select an option

Save omas/a8c66812857e2305beaf to your computer and use it in GitHub Desktop.
Perl を思い出してみる
#! /usr/bin/perl
use strict;
use warnings;
my ($length,@lines) = (<STDIN>,<STDIN>);
print(&total_price(@lines[0..$length -1]));
sub total_price {
my $total_price = 0;
foreach(@_) {
my @cols = split(/ /,$_);
my $shortage = $cols[0] - $cols[1];
my $price = $cols[2];
$total_price += $shortage * $price if $shortage > 0;
}
return $total_price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment