|< 1 2 >| | 18 Einträge, 2 Seiten |
1
2
Zitat (sri @ 09.04.2005, 18:49)
"channel spammer"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings;
our %opts;
my $lookup;
for (@ARGV) {$opts{$1}=$2 if (/([ABC]{1})=(\d+\.?\d*)/)}
$lookup = join '', sort keys %opts;
die "I need two sides!\n" unless (length($lookup)==2);
my $lut = {
'AB' => sub {return 'C='.sqrt($opts{A}**2+$opts{B}**2)},
'AC' => sub {return 'B='.sqrt($opts{C}**2-$opts{A}**2)},
'BC' => sub {return 'A='.sqrt($opts{C}**2-$opts{B}**2)},
};
print &{$lut->{$lookup}}, "\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
-w
print "\n Phytagorasrechner fuer C:\n\n";
print "\n Wert fuer A (in cm/ m): ";
chomp($a = <>);
print "\n Wert fuer B (in cm/ m): ";
chomp($b = <>);
$c =sqrt( $a**2 + $b**2);
printf("\n\n Berechneter Wert fuer C mit 2 Nachkommastellen: %.2f cm/ m\n", $c);
1
2
Zitat (sri @ 09.04.2005, 18:49)
"channel spammer"
|< 1 2 >| | 18 Einträge, 2 Seiten |