開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Dev-C++
問題(Question):
自己測output沒有問題,不曉得為什麼一直出現Runtime Error...
餵入的資料(Input):
10
move 9 onto 1
move 8 over 1
move 7 over 1
move 6 over 1
pile 8 over 6
pile 8 over 5
move 2 over 1
move 4 over 9
quit
預期的正確結果(Expected Output):
0: 0
1: 1 9 2 4
2:
3: 3
4:
5: 5 8 7 6
6:
7:
8:
9:
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/YeGwKn8o (已加註解)
補充說明(Supplement):
問題:http://uva.onlinejudge.org/external/1/101.html
41~46行:應該會在這裡讀到quit出去迴圈
如果下一個是EOF
31行:while (scanf("%d",&block) != -1)
在這行應該就會結束程式了
作者:
bluesoul (å¿™æ»ä½ è€çˆ¸)
2014-10-26 23:44:00107, 108有問題,你clear已經free,又去使用他Node* temp = clear->next;free(clear);clear = temp;這樣就可以
作者:
scwg ( )
2014-10-27 05:57:00你貼的改版沒改到問題... tmp=clear 只複製了位址, 那塊記憶體在 free(clear) 後就不能用了, tmp->next 跟 clear->next沒有差別, 都是未定義行為. 改成 bluesoul 的作法試試看?仔細看了一下, aelin 說得可能是問題所在? line 89 只防pileover, 其他三種指令碰到 a b 在同堆也會出錯吧而且你弄錯其他三種指令的意義了, 重讀一次題目...
作者: aelin 2014-10-27 22:03:00
我測 19 pile 2 onto 0 quit 就Segmentation fault了
作者:
scwg ( )
2014-10-28 07:03:00→ scwg: 而且你弄錯其他三種指令的意義了, 重讀一次題目...