【发布时间】:2019-05-30 16:47:15
【问题描述】:
我正在尝试寻找 3 个数字中最大的技术问题。问题如下
你只需要从标准输入中获取三个数字作为输入,你需要 找到其中最伟大的。
输入格式
您将分别从每行的标准输入中获取三个数字作为输入。
约束
-100000
输出格式
您需要将三个数字中最大的一个打印到标准输出。
示例测试用例 1
输入
902 100 666
我做到了
''' Read input from STDIN. Print your output to STDOUT '''
#Use input() to read input from STDIN and use print to write your output to STDOUT
import sys
def main():
s=sys.stdin.read()
s=s.split("\n")
a=int(s[0])
b=int(s[1])
c=int(s[2])
temp=0
e=[a,b,c]
for i in e:
if i > temp:
temp=i
print(temp)
'''if (a>b) and (a>c):
temp = a
elif (b>a) and (b>c):
temp = b
else:
temp = c
print(temp)'''
main()
它有预定义的输入 902、100、666。我的代码显示 902 输出,预期也显示 902,但显示失败,为什么?在上面的代码中,注释或未注释的东西都显示失败。
【问题讨论】:
-
如果三个数分别为-1、-2、-3会怎样?
标签: python python-3.x