Fortune Telling Collection - Comprehensive fortune-telling - How to realize decimal addition, subtraction, multiplication and division with shell language
How to realize decimal addition, subtraction, multiplication and division with shell language
I originally wrote a calculator with a shell: [root @ lixitingtestdir] # catcalculator.sh #! /bin/bashecho "Usage: 1+3, qisquit" while [1] do read-p "->; >str 1 & gt; & gt/dev/nulla = ` echo $ str | awk-F '+|-| * |/' ' { print $ 1 } ' ` if[$ a = = q]thenrakfib = ` echo $ str | awk-F '+|-| * |/ ' ' { print $ 2 } ' ` o = ` echo $ str | grep-o "[:punct:]" | grep-v " \ "` case $ oin+)awk ' begin { printf " = % . 2f \ n ",' $ a '+' $ b ' } '; ; -)awk'BEGIN{printf"=%.2f\n ",' $ a '-' $ b ' } '; ; \*)awk'BEGIN{printf"=%.2f\n ",' $ a ' * ' $ b ' }; /)if[$ b-eq0]thene CHO 0 cannotbedenominator! continue fiawk ' begin { printf " = % . 2f \ n ",' $ a '/' $ b ' } '; ; #^)awk'begin{printf"=%.2f\n",'$a'**'$b'}'; ; *) echo error; ; Esacdone just wrote the reverse output: [root @ lixitingtestdir] # catdaoxushuchu.sh #! /bin/bashecho "Usage: 123456, QIs quit " while[ 1]do echo-n " Pleaswenternumber:" readnif[$ n = = ' q ']thenrakfisd = 0 rev = " on = $ necho " $ n " while[$ n-gt0] dosd = $($ n % 10))# getRemaindern = $(($ n/ 10))# getnextdigi
- Previous article:Is fortune telling accurate?
- Next article:How long is the bracelet worn by Chow Tai Fook 15cm arm?
- Related articles
- The Artistic Inheritance of Northern Jiangsu Drum
- Fortune telling method pen _ fortune telling skills
- Net name fortune telling _ calculating net name.
- What unforgettable movie pictures do you have in mind?
- Schematic diagram of lifeline fracture interleaving How many kinds of lifeline fracture interleaving are there?
- Where is fortune telling in Yanggu _ Where is fortune telling in Yanggu more accurate?
- Fortune telling compass wallpaper _ Fortune telling compass wallpaper picture daquan
- Children's names
- What's the name of a fortune teller?
- Great fortune teller _ A truly capable fortune teller