box-o-sand/cli/ex01/d.pl

41 lines
567 B
Perl
Raw Normal View History

2011-01-06 03:32:28 +00:00
#!/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__