현재 위치 - 주공해몽공식사이트 - 무료 운세 - 셸 언어를 사용하여 십진수 덧셈, 뺄셈, 곱셈 및 나눗셈을 실현하는 방법

셸 언어를 사용하여 십진수 덧셈, 뺄셈, 곱셈 및 나눗셈을 실현하는 방법

셸이 있는 계산기를 썼습니다: [root @ lixitingtestdir] # cat calculator.sh #! /bin/bashecho "사용법: 1+3, QIs quit" while [1] do read-p "->; > str1> & gt/dev/nulla = `echo $ str | awk-f'+|-| * |/'{print $1}' 입니다 {print $2}'' o = `echo $ str | grep-o "[:punct:]" | grep-v "\" `case 을 눌러 섹션을 인쇄할 수도 있습니다 -)awk'BEGIN{printf"=%.2f\n ",'$ a '-' $ b'} ';; 을 눌러 섹션을 인쇄할 수도 있습니다 \*)awk'BEGIN{printf"=%.2f\n ",'$ a' *' $ b' };; /) if [$ b-eq0] thene CHO 0 cannotbedenominator! Continue fi awk' begin {printf "=% .2f \ n",' $ a '/' $ b'} ';; 을 눌러 섹션을 인쇄할 수도 있습니다 #) awk' begin {printf "=% .2f \ n",' $ a' * *' $ b'}'; 을 눌러 섹션을 인쇄할 수도 있습니다 *) 에코 오류; 을 눌러 섹션을 인쇄할 수도 있습니다 Esacdone 은 방금 역출력을 썼습니다: [root @ lixitingtestdir] # catdaoxushuchu.sh #! /bin/bashecho "사용법: 123456, Qis quit "while [1] do echo-n" pleaswenternumber: "readn if [$ n = =' q'] thenrer Dosd = $ ($ n%10)) # getremaindern = $ (($ n/10)) # getnext