题目描述编写一个程序,输入a、b、c三个值,输出其中最大值。输入一行数组,分别为a b c,输出a b c其中最大的数。
样例:输入10 20 30,样例输出30。
max = 0
a, b, c = map(int, input().split())
if a>b:
if a>c:
max = a
else:
max = c
elif b>c:
max = c
else:
max = c
print(max)
-
max = 0
:创建一个名为max
的变量并将其初始化为0。这个变量将用于存储找到的最大值。 -
a, b, c = map(int, input().split())
:这一行代码执行以下操作:input()
函数用于从用户输入中读取一行文本。split()
方法将输入的文本分割成多个字符串,以空格作为分隔符。map(int, ...)
将分割后的字符串列表转换为整数,并将它们赋值给变量a
,b
, 和c
。这样,你就得到了三个整数的输入值。