[問題] 判斷輸出問題

作者: oklp1415 (天生我材)   2014-08-16 18:59:32
開發平台(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):
作者: flydragon198 (Richard)   2014-08-16 20:00:00
這讓我想到String Matching: Knuth-Morris-Pratt
作者: oklp1415 (天生我材)   2014-08-16 21:33:00
因該不用這麼複雜,沒用到什麼資料結構的東西0.0
作者: candy3607 (大仁~)   2014-08-16 21:52:00
作者: Killercat (殺人貓™)   2014-08-16 22:44:00
KMP已經夠簡單了....
作者: keeper7478 (the Servant of Cthulhu)   2014-08-17 03:29:00
直接用 set?

Links booklink

Contact Us: admin [ a t ] ucptt.com