zoukankan      html  css  js  c++  java
  • Leaning perl 第2章练习题答案

    原文发表在网易博客 2010-11-04 21:18:43

    开始学习perl了,得多做题啊.

    image(让我对perl感兴趣的是小羊驼书,呃这个就是羊驼了,不过怎么感觉跟网络上某个神兽很像啊.)

    2.1-2.3 计算圆半径计算

    #!perl -w
    $PI=3.141592654;
    print "ENTER the semidiameter:";
    $semidiameter = <STDIN> ;
    chomp($semidiameter);
    if ($semidiameter < 0  ){
        $semidiameter=0;
        }
    $circumference=2*$PI*$semidiameter;
    print "circumference is $circumference";

    2.4计算两个数字的积
    #!perl -w

    print "Enter the first number(a):";
    chomp($a=<STDIN>);
    print "Enter the second number(b):";
    chomp($b=<STDIN>);
    $c=$a*$b;
    print "a*b is $c";

    2.5 将某个字符串打印一定次数

    #!perl -w
    print "Enter the character to print:";
    chomp($string_to_print=<STDIN>);
    print "Enter times to print:";
    chomp($times=<STDIN>);
    $result=${string_to_print} x $times;
    print "result is :$result";

        2011-05-25 22:33
        感谢大家的鼓励,这篇文章发表在网易博客上之后有人回复我哦.

  • 相关阅读:
    aws centos 基本环境安装
    aws 安装python解释器
    odoo 开发环境部署
    graphql规范
    python 字符串format使用
    设计模式
    集合的常见操作
    字典常见操作
    python实现简单的购物车
    python实现简单的登录管理
  • 原文地址:https://www.cnblogs.com/leipei2352/p/2057465.html
Copyright © 2011-2022 走看看