Leser: 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/usr/bin/perl -w # output format format OUT = @>>>>>>>>>>>>>>>>>>>@>>>>>>>>>>>>>>>>>>> $x, $y . open(IN, "input.inp"); open(OUT,">$ARGV[0]"); open(OUT2,">$ARGV[0].history"); print OUT " 0.1 0.1\n"; print OUT " 0.2 0.2\n"; print OUT " 0.3 0.3\n"; # read input file $k=0; while (<IN>){ $values{$k} = [ split ]; $k++; } @x = (4..10); $scalar= 0.1; @x = map { $_ * $scalar } @x; $y=a*$x^b write OUT; print OUT2 "$x $y\n"; close(IN); close(OUT); close(OUT2); print "N o r m a l\n";
1 2 3 4 5 6 7 8 9 10
use strict; use warnings; use IO::File; my $fh = IO::File->new; $fh->open('inputfile','r') or die $1; my @aub = <$fh>; $fh->close; # a und b in $aub[0] bzw. $aub[1]
Guest FekixFreue mich auf eure Verbesserungen
perl -Mbignum -s -e'print map { $_, "\t", $a * $_ ** $b, "\n" } map { $_ * 0.1 } 4..10' -- -a=23 -b=42
1
2
3
4
5
6
7
0.4 0.000000000000000444884701618183536291872768
0.5 0.000000000005229594535194337368011474609375
0.6 0.000000011068285478162611808170564468604928
0.7 0.000007175390092544474539930597401905449127
0.8 0.001956623609795396164914403992732667215872
0.9 0.275367849198926455137863020614492083430663
1 23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$k=0;
while (<IN>){
$values{$k} = [ split ];
$k++;
}
$a = $values{$k}[0];
$b = $values{$k+1}[0];
#$a = 400;
#$b = 0.2;
$x = 0.203-((1-0.203)/100);
for ($temp=1; $temp<102; $temp++){
$x = $x+((1-0.203)/100);
$y = $a+$x**$b;
write OUT;
print OUT2 "$x $y\n";
2019-07-10T12:40:17 Fekixeine Datei in der zwei Werte untereinander stehen. Die sollen als a und b eingelesen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
use strict; use warnings; use autodie; use bignum; my ($A, $B) = do { open my $fh, '<', 'input.inp'; $fh->getlines; }; chomp($A, $B); my $x = 0.203 - ((1 - 0.203) / 100); for (1 .. 101) { $x = $x + ((1 - 0.203) / 100); my $y = $A + $x ** $B; print "$x\t$y\n"; }
1 2 3
use Getopt::Long qw(GetOptions); my ($A, $B) = (400, 0.2); # default values if not passed as arguments GetOptions('A:f' => \$A, 'B:f' => \$B);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# read input file
$k=0;
while (<IN>){
$values{$k} = [ split ];
$k++;
}
$a = $values{0}[0];
$b = $values{1}[0];
$c = $values{2}[0];
$x = 0-((1)/350);
for ($temp=1; $temp<102; $temp++){
$x = $x+((1)/350);
$y = $a+$b*$x**$c;
write OUT;
print OUT2 "$x $y\n";
}
close(IN);
close(OUT);
close(OUT2);