[問題] 大數字加法
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
問題(Question):
寫出來的加法每次都無法進行
餵入的資料(Input):
兩個數字 123456 123456
預期的正確結果(Expected Output):
246912
錯誤結果(Wrong Output):
似乎是out of range 不過我百思不得其解
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ideone.com/GaHpy 我有寫一些備註
------------------------------------------------------
更新 這是我的 HugeInteger.cpp
http://ideone.com/nRoDA
這是我的HugeInteger.h
http://ideone.com/7mLDC
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.83.187
→
12/25 00:40, , 1F
12/25 00:40, 1F
→
12/25 00:40, , 2F
12/25 00:40, 2F
什麼意思??
我放了一個if的原因是因為要是到了最左邊還大於十的話就會溢位了
※ 編輯: steve1012 來自: 220.132.83.187 (12/25 00:43)
→
12/25 00:45, , 3F
12/25 00:45, 3F
→
12/25 00:45, , 4F
12/25 00:45, 4F
啊我蠢了
竟然忘記了
不過這樣還是不能跑耶
我打一下error message
他說
Debug Assertion Failed
...
...
...
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
※ 編輯: steve1012 來自: 220.132.83.187 (12/25 00:49)
然後我有看過compiler好像每次都是在
for( int i = IntegerSize-1 ; i >=0 ;i--)這行錯掉
另外補充一下我存大數的陣列長度是IntegerSize(預設40)
→
12/25 00:51, , 5F
12/25 00:51, 5F
可是我沒有用到Free耶 只有在destructor的時候delete了我宣告的陣列
我在原文補充了我整個class
※ 編輯: steve1012 來自: 220.132.83.187 (12/25 00:54)
→
12/25 01:06, , 6F
12/25 01:06, 6F
真的..
太強了!
※ 編輯: steve1012 來自: 114.34.202.142 (12/25 11:01)
討論串 (同標題文章)