亚洲精品中文免费|亚洲日韩中文字幕制服|久久精品亚洲免费|一本之道久久免费

<optgroup id="cczp1"><ruby id="cczp1"><cite id="cczp1"></cite></ruby></optgroup>
  • <acronym id="cczp1"></acronym>
    <acronym id="cczp1"><option id="cczp1"><ol id="cczp1"></ol></option></acronym>
    <delect id="cczp1"></delect>
    <center id="cczp1"></center>
    <delect id="cczp1"></delect><em id="cczp1"><button id="cczp1"><blockquote id="cczp1"></blockquote></button></em>
    1. <optgroup id="cczp1"><td id="cczp1"><dfn id="cczp1"></dfn></td></optgroup>

      linux中的shell 使用for循環(huán)來求n的階層

      shell的的有很多要注意的地方,程序邏輯簡單,但是語法細(xì)節(jié)比較多

      #!/bin/bashfact(){#if 后必須要有空格if [[ $1<=1 ]]then echo 1elselocal j=$(($1-1))#local tmp=$( fact $1-1 ) #此處寫法錯(cuò)誤的寫法#等號(hào)后不能有空格local tmp=$( fact $j)#local res=$(($tmp * $1 ))#利用輸出流 解決$? 最大值255的問題echo $(( $tmp * $1 ))fi}echo "enter your number:"read numecho "you put is :$num"#等號(hào)后面不能有空格,否則報(bào)錯(cuò),以下兩句是等價(jià)的rs=$(fact $num )#rs=`fact $num`echo $rs

      需要注意的的是,local tmp=$( fact $1-1 )是錯(cuò)誤的,不知道有沒有更

      正確的寫法是

      local j=$(($1-1))

      local tmp=$( fact $j)

      等號(hào)后不能有空格,如 rs= $(fact $num ) 將報(bào)錯(cuò)

      #if 后面必須要有空格

      if [[ $1<=1 ]]

      鄭重聲明:本文內(nèi)容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場,版權(quán)歸原作者所有,如有侵權(quán)請聯(lián)系管理員(admin#wlmqw.com)刪除。
      用戶投稿
      上一篇 2022年6月16日 18:17
      下一篇 2022年6月16日 18:18

      相關(guān)推薦

      聯(lián)系我們

      聯(lián)系郵箱:admin#wlmqw.com
      工作時(shí)間:周一至周五,10:30-18:30,節(jié)假日休息