[問題] gcc 編譯器問題

作者: ho83leo (LWHo)   2015-12-15 00:54:46
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
gcc 4.9.2 and 4.9.3 and 5.2.0
linux gcc 4.9.2
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
在windows 10 x64 安裝了 cygwin x86(因IDE因素所以上x86),
剛剛windows 編譯的時候, 可以安全safe, 但是印出後 卻是很長一段數值,
可是加總後的總數卻是正確的...
餵入的資料(Input):
五個參數 8 6 3.0 0.2 1.0
預期的正確結果(Expected Output):
在linux 執行結果為圖
https://goo.gl/4Xqcj9
錯誤結果(Wrong Output):
windows 10 cygwin x86 gcc 4.9.2 / 4.9.3 / 5.X.X 都同樣錯誤結果
https://goo.gl/tdyNCH
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/dOURJdAZ
補充說明(Supplement):
求各位大大解惑也!!!
作者: LPH66 (-6.2598534e+18f)   2015-12-15 01:24:00
你的 total 一開始沒有歸零, 後來是對的是因為 32 行歸零了只宣告沒給初值的變數其內容不可預測
作者: ho83leo (LWHo)   2015-12-15 09:34:00
感謝解答... 犯這種錯誤真是粗心

Links booklink

Contact Us: admin [ a t ] ucptt.com