电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

Perl语言入门(第四版)习题答案VIP免费

Perl语言入门(第四版)习题答案_第1页
1/23
Perl语言入门(第四版)习题答案_第2页
2/23
Perl语言入门(第四版)习题答案_第3页
3/23
《Perl 语言入门习题答案》 2 .1 2 练习 1 、写一个程序,计算半径为12.5的圆的周长。圆周长等于2π(π约为3.1415926)乘以半径。答案为78.5。 -----------------------/home/confish/perl/girth #!/usr/bin/perl -w #this program calculate a circle's girth #****************** $r=12.5; $g=12.5*2*3.1415; print "the girth of the circle is $g\n"; -----------------------/home/confish/perl/girth 2 、修改上述程序,用户可以在程序运行时输入半径。如果,用户输入12.5,则应得到和上题一样的结果。 -----------------------/home/confish/perl/girthpro #!/usr/bin/perl -w #a better one to calculate girth #****************** print"enter the radius of the circle\n"; chomp($r=); if($r>0) { print"the girth of the circle is ".$r*2*3.1415."\n"; } else { print"nonavailable!\n"; } -----------------------/home/confish/perl/girthpro 3 、修改上述程序,当用户输入小于0 的数字时,程序输出的周长为0,而非负数。 -----------------------/home/confish/perl/girthzero #!/usr/bin/perl -w #calculate the girth and print 0 when the radius is lower than 0 #****************** print"enter the radius of the line\n"; chomp($r=); if($r>0) { print"the girth of the circle is $r*2*3.1415\n"; } else { print"the girth of the circle is 0\n"; } -----------------------/home/confish/perl/girthzero 1 、2 、3 :(一起实现的) #!/usr/bin/perl -w $pai=3.141592654; print "Please Input Radius:"; $r=; if ( $r lt 0 ){ print "The circumference is 0\n"; }else{ $l=$r*2*$pai; printf "The circumference is %.1f\n",$l; } 4 、写一个程序,用户能输入2 个数字(不在同一行)。输出为这两个数的积。 -----------------------/home/confish/perl/product #!/usr/bin/perl -w #print the two number's product #******************print"enter the two numbers:\n"; chomp($m=); chomp($n=); print"the product of the two numbers are ".$m*$n."\n"; -----------------------/home/confish...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

Perl语言入门(第四版)习题答案

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部