[問題] 排列數字有誤(已解決!

作者: jerryhey (jerryhey)   2022-01-18 16:17:21
開發平台(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~~~感恩
作者: nh60211as   2022-01-18 18:28:00
大概把a刪掉改用count就差不多了
作者: sarafciel (Cattuz)   2022-01-18 19:24:00
你的count++之後 score[count]會是多少?
作者: jerryhey (jerryhey)   2022-01-19 00:46:00
我把count++拿掉sum的下一行加a++平均的地方除a就解決了

Links booklink

Contact Us: admin [ a t ] ucptt.com