box-o-sand/cli/exercise_01/d.pl
2011-01-05 22:32:28 -05:00

41 lines
567 B
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use Math::Complex;
print "Entrez-vous\n";
my ($a, $b, $c) = (rand(100), rand(100), rand(100));
print "\$a=$a\n";
print "\$b=$b\n";
print "\$c=$c\n";
sub quad {
my ($a, $b, $c) = @_;
my $positive = (
($b * -1) - sqrt(($b ** 2) - (4 * ($a * $c))) / (2 * $a)
);
my $negative = (
($b * -1) + sqrt(($b ** 2) - (4 * ($a * $c))) / (2 * $a)
);
return ($positive, $negative);
}
my @result = quad($a, $b, $c);
printf("%s, %s\n", $result[0], $result[1]);
1;
__END__
1;
__END__