看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Win10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) c++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 在排列數字的時候找不到正確的值 餵入的資料(Input): 56 89 67 101 預期的正確結果(Expected Output): 89 67 56 錯誤結果(Wrong Output): 101 0 0 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) https://ideone.com/h9JHp5 補充說明(Supplement): 排列數字的時候有錯 找不到原因 最大值都是101 往下排列數字都是0 阿不然就是溢位(-85640) 麻煩各位幫我debug~~~感恩 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.115.152.91 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1642493845.A.BAA.html
kobe8112: 我只瞄了幾行,你的a從頭到尾不都一樣嗎XD
01/18 17:18 你的意思是說不能用while 的意思嗎! ※ 編輯: jerryhey (140.115.152.91 臺灣), 01/18/2022 18:00:29
nh60211as: 大概把a刪掉改用count就差不多了01/18 18:28
我試試! 這樣變成總分平均變成0了 ※ 編輯: jerryhey (101.136.223.73 臺灣), 01/18/2022 18:37:23 ※ 編輯: jerryhey (101.136.223.73 臺灣), 01/18/2022 19:14:15 ※ 編輯: jerryhey (101.136.223.73 臺灣), 01/18/2022 19:22:01
sarafciel: 你的count++之後 score[count]會是多少? 01/18 19:24
jerryhey: 我把count++拿掉 01/19 00:46
jerryhey: sum的下一行加a++ 01/19 00:46
jerryhey: 平均的地方除a 01/19 00:46
jerryhey: 就解決了 01/19 00:46