Friday 10 April 2020

【Python解題】Python-TQC題庫-210 三角形判斷

Python-TQC題庫-210 三角形判斷

請使用選擇敘述撰寫一程式,讓使用者輸入三個邊長,檢查這三個邊長是否可以組成一個三角形。若可以,則輸出該三角形之周長;否則顯示【Invalid】。

提示:檢查方法 = 任意兩個邊長之總和大於第三邊長。

【輸入說明】
三個正整數
【輸出說明】
可以組成三角形則輸出周長;否則顯示Invalid

【解法1】
#t means triangle
t1 = int(input())
t2 = int(input())
t3 = int(input())

sumT = [t1,t2,t3]

if (t1+t2>t3) or (t1+t3>t2) or (t2+t3 >t1) :
   print (sumT)
else:
   print("Invalid")


【解法2】

No comments:

Post a Comment

找不到匯入的專案  請確認 <Import> 宣告中的路徑正確,而且檔案存在於磁碟上。

【Problem】  C:\inetpub\wwwroot\project\project.csproj : error  : 找不到匯入的專案 "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\W...