I used shell to write it. At that time, I had a little understanding of it. Now I completely forgot it. But I still can understand it, so I won't write it. They are all simple questions assigned by teachers.
1. Select addition, subtraction, multiplication, division, and enter two numbers and results to check whether the user input results are correct.
#! /Bin/bash <br/> # This is the first homework <br/> echo "input 1 to start and other numbers to exit: "<br/> Read sig <br/> while [$ sig-EQ 1] <br/> DO <br/> echo-n" Please choose (+ ,-, *,/) "<br/> read operation <br/> echo-n" Please input the 2 numbers to calculate: "<br/> Read a B <br/> declare C <br/> echo-n" Please input the result: "<br/> Read result <br/> Mul = * <br/> If [" $ operation "=" $ Mul "] <br/> T Export c = 'expr $ A/* $ B '<br/> Elif [$ operation = +] <br/> then c = 'expr $ A + $ B' <br /> Elif [$ operation =-] <br/> then c = 'expr $ A-$ B '<br/> Elif [$ operation =/] <br/> then C = 'expr $ A/$ B '<br/> else <br/> echo "error" <br/> Exit 1 <br/> fi <br/> If [$ result-EQ $ C] <br/> then Echo "you are right! "<Br/> else echo" You are wrong, the right answer is $ C! "<Br/> fi <br/> echo" input 1 to start again and any other numbers to exit "<br/> Read sig <br/> done <br/> echo "goodbye!"
2. Sort the three input numbers in ascending order.
#! /Bin/bash <br/> # This is the second homework <br/> function order <br/> {<br/> If [$ C-GT $ A] <br /> then <br/> T = $ C <br/> C = $ A <br/> A = $ T <br/> fi <br/> If [$ B -GT $ A] <br/> then <br/> T = $ A <br/> A = $ B <br/> B = $ T <br/> fi <br/> If [$ C-GT $ B] <br/> then <br/> T = $ C <br/> C = $ B <br/> B = $ T <br/> fi <br/>}</P> <p> echo-n "Please input 3 numbers: "<br/> Read a B c <br/> order a B c <br/> echo" $ A $ B $ C "<br/>