[問題] leetcode Runtime Error消失

看板C_and_CPP (C/C++)作者時間9年前 (2017/01/07 01:34), 9年前編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: Win10, Linux, ...) win7 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) gcc 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) no 問題(Question): 在練習leetcode的283 Move Zeroes 程式寫好了自己測試沒問題 可是網頁上出現了runtime error 按進去細節什麼都沒寫 就只有 "Last executed input: [4,2,4,0,0,3,0,5,1,0]" 我把出現錯誤的那筆資料拿來自己電腦上輸入 可以得到正確結果 想請問一下這樣可能是什麼狀況 餵入的資料(Input): 4,2,4,0,0,3,0,5,1,0 預期的正確結果(Expected Output): 4243510000 錯誤結果(Wrong Output): runtime error 程式碼(Code):(請善用置底文網頁, 記得排版) http://codepad.org/bKc9N5vK 補充說明(Supplement): 題目連結在此 https://leetcode.com/problems/move-zeroes/ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 66.86.130.129 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1483724071.A.2E7.html ※ 編輯: nikuman (66.86.130.129), 01/07/2017 01:34:58

01/07 01:49, , 1F
main裡補上return 0 ?
01/07 01:49, 1F

01/07 01:51, , 2F
我看錯了Q
01/07 01:51, 2F

01/07 02:16, , 3F
input: [0] 你在14行會access到nums[1]
01/07 02:16, 3F
input the size of array 1 input the array 0 the output is 0 測試的結果輸入0還是得到0 所以是電腦在執行的內部錯誤嗎QQ ※ 編輯: nikuman (66.86.130.129), 01/07/2017 03:41:25

01/07 13:31, , 4F
access到錯誤的位置 要發生什麼沒辦法保證
01/07 13:31, 4F

01/07 16:31, , 5F
提示在O(n)達成。
01/07 16:31, 5F
文章代碼(AID): #1ORzKdBd (C_and_CPP)
文章代碼(AID): #1ORzKdBd (C_and_CPP)