[問題] stl的stack問題

看板C_and_CPP作者 (是黑是白)時間14年前 (2011/03/29 04:11), 編輯推噓0(006)
留言6則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Dev C 問題(Question): 程式會當掉 debug很久都沒有收穫ˊˋ 這程式是要測試輸入的大小括弧()/[]是不是對稱存在 不過只要遇到右括弧數量比左括弧多,就會當掉 完全沒頭緒... 餵入的資料(Input): (([()]))) 程式碼(Code):(請善用置底文網頁, 記得排版) http://codepad.org/gU35ZpFX 第一次用STL,還在熟悉中.. 麻煩神手大大們幫忙解惑Orz -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.112.197

03/29 04:40, , 1F
top returns a reference to the top element in th
03/29 04:40, 1F

03/29 04:41, , 2F
stack. if there's nothing in the stack, the behavior
03/29 04:41, 2F

03/29 04:41, , 3F
is undefined.
03/29 04:41, 3F

03/29 04:44, , 4F
你input的最後一個")"並不會被push進stack中,因為前面的
03/29 04:44, 4F

03/29 04:46, , 5F
if(input[i] == ')')...
03/29 04:46, 5F

03/29 13:32, , 6F
感謝樓上二位!!
03/29 13:32, 6F
文章代碼(AID): #1DaEjlB7 (C_and_CPP)