任意三個數,判斷最大數
思路:1.先要輸出三個數字
2.假設第一個數字是最大數
3.用第二個數字和第一個數字對比,如果第二個數字大最大值就變成第二個數字
4.用第三個數字和第一個數字對比,如果第三個數字大最大值就變成第三個數字
5.輸出最大的數字
vim duibi.sh
#!/bin/bash
#written by lizheng
#about duibi
echo "please enter three number:"
read -p "the first number is:" n1
read -p "the second number is:" n2
read -p "the third number is:" n3
let max=$n1
if [ $n2 -ge $n2 ] ;then
max=$n2
fi
if [ $n3 -ge $n1 ] ;then
max=$n3
fi
echo "the max number is $max."