余詠詩 2022-8-24 18:58
檢查 check[value]這個陣列是否等於0,如果等於0會用兩個格顯示value整數,所以兩個整數之間有兩個空格,最後 check[value]=1
小黑 2022-8-24 20:00
[quote]原帖由 [i]粉紅仔[/i] 於 2022-8-24 18:08 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551482991&ptid=30733591][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
圖裏標示顏色的代碼唔明點解,求高手指教,謝謝!
[img]https://img.discuss.com.hk/d/attachments/day_220824/20220824_af3644790d34558db26bYdKctVbrFgVI.jpg[/img] [/quote]
The check array stores the states (visited or not) of the 10 numeric digits (0-9).
Value 0 for 'not visited'. Value 1 for 'visited'.
For example, if check[3] == 0, the digit 3 is new (first encountered).
The assignment check[3] = 1 will change the state from 'not visited' to 'visited'.
If another 3 is encountered, it is ignored as check[3] == 1 (visited).
[[i] 本帖最後由 小黑 於 2022-8-24 20:01 編輯 [/i]]
余詠詩 2022-8-24 20:31
[quote]原帖由 [i]粉紅仔[/i] 於 2022-8-24 19:26 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551485204&ptid=30733591][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
謝謝回覆
但我想知道這3行點解會把重覆的數字刪除掉? 請指教,謝謝 [/quote]
令到佢刪除唔只果3行,仲有第18果行,第21果行令到佢下次相同時唔再執行第20同21果行
Zzlaz 2022-8-28 14:17
做counter
0 代表無出現過,1 代表出現過
第一次出現,print出來,改狀態為1
之後再見到就唔print
C都好似有boolean?
#include <stdbool.h>