在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    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é)假日休息