Linux下用Bash语言实现输出最大值的功能

题目链接:

题目描述

编写一个程序,输入a、b、c三个值,输出其中最大值。

输入

一行数组,分别为a b c

输出

a b c其中最大的数

样例输入

10 20 30

样例输出

30

复习下Linux和Bash 

 1 #!/bin/bash
 2 read x read y read z
 3 tem=$x
 4 if [ $y -gt $tem ]
 5 then
 6 tem=$y
 7 else
 8 tem=$tem
 9 fi
10 if [ $z -gt $tem ]
11 then
12 tem=$z
13 else
14 tem=$tem
15 fi
16 echo $tem

猜你喜欢

转载自www.cnblogs.com/shixinzei/p/10842649.html