type Tmyset = set of 基本型態;
其中基本型態,指的是序數型態(ordinal),且個數不得大於256 (0 到 255)。
範例:
type
T1=1..10;
T2= (Red, Yellow, Green);
T3='A'..'F';
Tset1 = set of T1;
Tset2 = set of T2;
Tset3 = set of T3;
var
a: Tset1;
b: Tset2;
c: Tset3;
或簡化為
var
a: set of 1..10;
b: set of (Red, Yellow, Green);
c: set of 'A'..'F';
下列範例超過256將有錯誤產生
var
d: set of integer;
e: set of real;
f: set of string;
g: set of char;
集合的設定
a:= [1,2,3];
b:=[Red, Green];
c:[A,D];
集合的運算
+, - , * , <=, >= , = , <>, in
沒有留言:
張貼留言