[問題] 找直角三角形的值已刪文

看板Python作者 (雄商都敏俊)時間5年前 (2019/12/01 17:43), 編輯推噓3(415)
留言10則, 7人參與, 5年前最新討論串1/1
各位大大好! 有個關於Python的程式作業問題,問題如下: Assume that there is a right triangle which has three integer sides and the th ree sides of course satisfy the Pythagoras theorem. Please use Python to write function(s) to find out all side-sets including sid e1,side2,and the hypotenuse(use list or tuple or dict to store the data) and a ll the sides are no larger than 500. 渣翻譯:用函數求直角三角形的邊(不大於500),邊的值需要符合畢氏定理(直角邊的 平方和需等於斜邊長的平方),存值的方式可以用list,tuple,dict。 求各位大大幫忙,非常感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.77.173.141 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1575193417.A.FB7.html

12/01 17:56, 5年前 , 1F
提示:三層for loop 用畢氏定理當if的條件
12/01 17:56, 1F

12/01 18:05, 5年前 , 2F
兩個for?
12/01 18:05, 2F

12/01 18:54, 5年前 , 3F
你應該先說自己卡在哪邊.....而不是要大家幫忙寫作業
12/01 18:54, 3F

12/01 18:59, 5年前 , 4F
一開始就兩層loop if第三邊=整數 再慢慢刻 因為有些三
12/01 18:59, 4F

12/01 18:59, 5年前 , 5F
角全等的關係其實一邊不用掃完1-500
12/01 18:59, 5F

12/01 19:01, 5年前 , 6F
或是a固定時b超過多少c會大於500後面可以直接跳過這圈
12/01 19:01, 6F

12/01 22:02, 5年前 , 7F
for i in range(1,500):
12/01 22:02, 7F

12/01 22:02, 5年前 , 8F
我已經幫你寫完一半了,剩下自己寫,不用謝我
12/01 22:02, 8F

12/01 22:05, 5年前 , 9F
感謝各位大大,問題已經解決了!
12/01 22:05, 9F

12/02 02:17, 5年前 , 10F
這不難吧,用for一下子就寫出來了
12/02 02:17, 10F
文章代碼(AID): #1Tuuj9-t (Python)
文章代碼(AID): #1Tuuj9-t (Python)