首页 > 编程语言 >用python求三个数中最大的奇数,主要用branching语法

用python求三个数中最大的奇数,主要用branching语法

时间:2023-01-25 19:34:04浏览次数:59  
标签:branching num2% num1 num2 num3 python else biggest 数中

#Find the largest odd number among 3 numbers
num1=int(input("请输入第一个数:"))
num2=int(input("请输入第二个数:"))
num3=int(input("请输入第三个数:"))
if num1%2==0 and num2%2==0:
    if num3%2!=0:
        biggest=num3
    else:print("这三个数都不是奇数")
elif num1%2==0 and num2%2!=0:
    if num3%2==0 or num2>num3:
        biggest=num2
    else:biggest=num3
elif num1%2!=0 and num2%2==0:
    if num3%2==0 or num1>num3:
        biggest=num1
    else:biggest=num3
elif num1%2!=0 and num2%2!=0:
    if num3%2!=0:
        biggest=num1
        if biggest<num2:
            biggest=num2
        if biggest<num3:
            biggest=num3
    elif num1>num2:
        biggest=num1
    else:biggest=num2
    print("三个数中最大的奇数为:%s"% biggest)

标签:branching,num2%,num1,num2,num3,python,else,biggest,数中
From: https://www.cnblogs.com/evanchn/p/17067165.html

相关文章