作者keke0421 (zrae)
看板C_and_CPP
標題[問題] UVA272-Time limit exceeded 求解
時間Mon Aug 3 19:07:23 2015
各位大大好
這題的大意主要是 改變 文字中的雙引號
input ->
"To be or not to be," quoth the Bard, "that
is the question".
output->
``To be or not to be," quoth the Bard, "that
is the question''.
我的code如下:
http://codepad.org/AYeQu33e
想不太出來 效率可能會慢在哪裡QQ
應該不會是本身string提供的member function ( find , replace...)很慢吧?
我知道我可以用檢查的字元方式 再去跑for迴圈檢查 來替換
但還是想知道到底 問題在哪呢QQ
感謝 :)
ps: 會有兩個 if的檢查式 是因為 uva的測資 有一些會有單一個引號的問題
這樣會造成 runtime error 所以才加了第二個
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.171.16.131
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1438600046.A.6DC.html
→ Feis: 孩子, 這是個無窮迴圈。 08/03 19:22
→ Feis: BTW, 這寫法應該是錯的 08/03 19:27
→ Feis: 你可能會錯題目的意思了 08/03 19:32
→ keke0421: 感謝提醒:) 08/03 22:45