線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1096
推到 Plurk!
推到 Facebook!

請問如何用Set 實現下列功能?

尚未結案
mathewzhao
中階會員


發表:121
回覆:164
積分:67
註冊:2003-04-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-30 11:45:32 IP:61.185.xxx.xxx 未訂閱
各位先進好 ! 請問如何用Set 實現下列功能: // if (62 in [70,80,62 ]) then
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-30 11:52:39 IP:147.8.xxx.xxx 未訂閱
var
    MySet : set of byte;
begin
    MySet := [70,80,62];
    if 62 in MySet then begin
    end;
end;
mathewzhao
中階會員


發表:121
回覆:164
積分:67
註冊:2003-04-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-30 12:45:18 IP:219.145.xxx.xxx 未訂閱
Hi! William 兄 ,感謝你的回應! 如果是 // > //
ha0009
版主


發表:16
回覆:507
積分:639
註冊:2002-03-16

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-05-30 13:12:06 IP:61.30.xxx.xxx 未訂閱
呵呵.. 如果我沒搞錯的話, Set 元素最多 256 個喔!!  所以應該不能這麼做吧 如果要這樣做不妨使用
mathewzhao
中階會員


發表:121
回覆:164
積分:67
註冊:2003-04-04

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-05-30 14:00:45 IP:219.145.xxx.xxx 未訂閱
Hi! Ha0009‧ 你說的沒錯!可是這個Set 只有3個元素呀!
ha0009
版主


發表:16
回覆:507
積分:639
註冊:2002-03-16

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-05-30 14:15:45 IP:61.30.xxx.xxx 未訂閱
william 兄的宣告剛好在 256 個元素內,所以能夠成功定義 MySet 但你的宣告卻已經超出了 256 個元素的限制,所以你不能成功呀 < > 這是我的淺見啦,或許有前輩們有別的辦法喔< >
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-05-30 14:28:48 IP:147.8.xxx.xxx 未訂閱
hua0009 is correct, you cannot declare a set of integer since a set is limited to 256 elements. Although inefficient, a TStringList may be used, e.g.    
S := TStringList.Create;
S.Add('70');
S.Add('80');
S.Add('62');
if S.IndexOf('62')>=0 then begin
end;
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-05-30 14:31:03 IP:218.16.xxx.xxx 未訂閱
From Help : sets (set types)    A set is a collection of values of the same ordinal type. The values have no inherent order, nor is it meaningful for a value to be included twice in a set.    The range of a set type is the power set of a specific ordinal type, called the base type; that is, the possible values of the set type are all the subsets of the base type, including the empty set. The base type can have no more than 256 possible values, and their ordinalities must fall between 0 and 255. 這說明了是 Set 的 Base Type 要是不能超過 255 個值 的 Ordinal Type,而不是說你 set 裡面有多少個值。 Interger 的可能值遠遠超過了 255 所以不能使用 試試我剛寫的 isIn 函數罷,有問題請告知喔 : 模擬 in operator 但能使用於各種形態的函數 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=31477 if isIn(62888888,VarArrayOf([70555555,80000000,62888888])) then .....
系統時間:2024-05-05 18:34:05
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!