看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Dev-C++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) ....先前一些零粹的code就不PO上來了 以下是我要判斷的條件輸出程式碼 int q[5]; for(c=0,d=0;c<5;c++){ for(e=0;e<5;e++){ if(a[c]!=a[e]){ q[c]=a[c]; } for(int j=0;j<5;j++){ printf("%d",q[j]); } } } } 比如說輸入一串數字 1 2 3 4 5 1 2 3 5 6 輸出會是 1 2 3 4 5 6 意思把前面重複的數字刪除 我做法是每往下一個,判斷後重頭再跑一次判斷,額外存入另一個變數內 最後依序輸出不知道這樣做法哪裡錯誤了~"~一直弄不出來 求解~.~thanks 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.171.35.28 ※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1408186775.A.6D3.html
flydragon198: 這讓我想到String Matching: Knuth-Morris-Pratt 08/16 20:00
oklp1415: 因該不用這麼複雜,沒用到什麼資料結構的東西0.0 08/16 21:33
candy3607: http://codepad.org/Ry3y81xh 這樣子? 08/16 21:52
Killercat: KMP已經夠簡單了.... 08/16 22:44
keeper7478: 直接用 set? 08/17 03:29