比如 TState = (a, b, c, d);
TStatus = set of TState;var
 s: TStatus;怎么判断s里是否包含了a和c
用in的话,只能判断一个吧,难道要一层层的if判断?如果属性多了,写起来比较麻烦啊

解决方案 »

  1.   

    忘记说,假设现在属性有a,b,c
    用=号就不行了
      

  2.   

    type
      ta = (a,b,c,d);
      tb = set of ta;
    var
      x1,x2: tb;
    begin
      x1 := [a,b];
      x2 := [a,b,c,d];
      if x1 <= x2 then
        ShowMessage('x1 <= x2');
      if x1 >= x2 then
        ShowMessage('x1 >= x2');
      if x1 = x2 then
        ShowMessage('x1 = x2');
      if x1 <> x2 then
        ShowMessage('x1 <> x2');
      

  3.   

    用交集,結果是a和c,就表示存在const CompareSet=[a]+[c];var
     s: TStatus;
    begin
       s:=[a]+[c]+[d];
       if s*CompareSet=CompareSet  then
         showmessage('s中包含CompareSet');
    end;
      

  4.   

    慢了呵,TState好像是DELPHI的一个类吧,LZ用的不会有问题?
      

  5.   

    s:=[a]+[c]+[d];
    可以這樣表示
    s:=[a,c,d];