編寫一個讀取三個整數並打印哪個值較大的程序。你的程序必須被命名爲biggest.py並且可以由主功能,然後在主函數cs類的python條件
這裏打電話的是我寫的:
def main():
a = int(input("the first integer? "))
b = int(input("the second integer? "))
c = int(input("the third integer? "))
if a > b > c:
print("the first integer is the largest")
elif b > a > c:
print("the second integer is the largest")
elif c > a > c:
print("the third integer is the largest")
main()
然而,當我運行的程序是要求輸入整數,但沒有給我任何結果後,我輸入整數
第三個elif永遠不會被觸發。除非按遞減順序輸入整數或者輸入中,高,低,否則不會得到輸出。 – StephenTG
3個數字有6種可能的排列組合。你確定3個條件足夠了嗎? – timrau
嘗試在Python解釋器中運行代碼以確定邏輯中的錯誤。更重要的是,在嘗試編寫代碼之前,我會試着在紙上做這件事。 –