MCU and embedded system exam shell Programming question Bank, simply made the next.
9. Similar to the title 7, there is a multiplication operation.
#!/bin/bash# test1.SH# 2016.1.2 Echo "Please input N student grade:"Read-A grade for((i=0; i<${#grade [@]};i++)) Do if[[${grade[i]}-ge - ]] ThenGrade[i]=5 elif[[${grade[i]}-ge the ]] ThenGrade[i]=4 elif[[${grade[i]}-ge - ]] ThenGrade[i]=3 elif[[${grade[i]}-ge - ]] ThenGrade[i]=2 ElseGrade[i]=1 fi Done#Echo${grade[*]}Echo${grade[*]} > Score.dat
#!/bin/bash# test2.SH# 2016.1.2Echo "Please input N number:"Read-a arr for((i=0; i<${#arr [@]};i++)) Do for(j=${#arr [@]}-1; j>i;j--)) Do if[[${arr[j]}-lt ${arr[j-1]} ]] ThenT=${arr[j]} Arr[j]=${arr[j-1]} arr[j-1]=$tfi Done DoneEcho${arr[*]} > Result.dat
#!/bin/bash# test3. SH 2016.1. 2 /homeif test-e Tesh. SH then RM Tesh. SH Else Touch Tesh. SH fi
#!/bin/bash# test4.SH# 2016.1.2if[-Z" $" ] Then Echo "You should input N num!"Exit1fiMax=$1min=$1 forNuminch$* Do if[$num-GT $max] ThenMax=$numfi if[$num-LT $min] Thenmin=$numfi DoneEcho "Max: $max, Min: $min"
#!/bin/bash# test5. SH 2016.1. 2 J=0; for ((i=1; i<=; i++)) Do J= 'expr $i + $j 'doneecho $j
#!/bin/bash# Test6.SH# 2016.1.2Echo "Input 1 Char:"read aif[$a ='Y' ] Then Echo "right!"elif[$a ='N' ] Then Echo "wrong!"Else Echo "Bad input!"fi
#!/bin/bash# test7.SH# 2016.1.2Echo "Input 2 Number:"Read Aread bEcho "Input + or-:"Read OPif[$OP ='+' ] Thenx=`Expr$a +$b 'elif[$OP ='-' ] Thenx=`Expr$a-$b 'fiEcho$x
#!/bin/bash# test8. SH 2016.1. 2 /homeif test-D examthen RM -r exam else mkdir examfi
#!/bin/bash# Test9.SH# 2016.1.2Echo "Input 2 Number:"Read Aread bEcho "Input + or-or x:"Read OPif[$OP ='+' ] Thenx=`Expr$a +$b 'elif[$OP ='-' ] Thenx=`Expr$a-$b 'elif[$OP ='x' ] Thenx=`Expr$a \*$b 'fiEcho$x
Ok!
Embedded Exam Shell Programming problem