彪彪
openkore
全部博文(50)
C编程(0)
软件工具(0)
c++入门(2)
openkore(0)
2010年(38)
2009年(12)
kevin258
wsy52081
ddmumahh
vincerma
raveh
mwx1234
chen_xue
zjwmv
zpbobo11
分类:
2009-12-14 14:59:20
#!/usr/bin/perluse strict;sub funmix {my ($agr1,$agr2) = @_;return $$agr1 < $$agr2 ? $agr1 : $agr2;}sub funmax {my ($agr1,$agr2) = @_;return $$agr1 > $$agr2 ? $agr1 : $agr2;}print "输入数字:";chomp(my $biao = <STDIN>);my $n1 = 0;my $n2 = 1;for(my $x = 1; $x <= $biao;$x++) {${funmix(\$n1,\$n2)} = $n1 + $n2;print ${funmax(\$n1,\$n2)};print "\n";}print "\n回车退出";<STDIN>;
代码二:
#!/usr/bin/perluse strict;print "输入数字:";chomp(my $biao = <STDIN>);my $n1 = 0;my $n2 = 1;for(my $x = 1; $x <= $biao;$x++) {($n1 < $n2 ? $n1 : $n2) = $n1 + $n2;print ($n1 > $n2 ? $n1 : $n2);print "\n";}print "\n回车退出";<STDIN>;
上一篇:斐波纳奇数列 非递归
下一篇:输出斐波纳奇数列
登录 注册