1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| bool CheckElem(const SqList& L) { for (int i = 0; i < L.length; ++i) { for (int j = i + 1; j < L.length; ++j) { if (L.data[i] == L.data[j]) return false; } } return true; }
SqList Union(const SqList& La, const SqList& Lb) { SqList Lc; InitList(Lc); for (int i = 0; i < La.length; ++i) { InsElem(Lc, La.data[i], Lc.length + 1); } for (int i = 0; i < Lb.length; ++i) { if (LocElem(La, Lb.data[i]) == 0) { InsElem(Lc, Lb.data[i], Lc.length + 1); } } return Lc; }
SqList Difference(const SqList& La, const SqList& Lb) { SqList Lc; InitList(Lc); for (int i = 0; i < La.length; ++i) { if (LocElem(Lb, La.data[i]) == 0) { InsElem(Lc, La.data[i], Lc.length + 1); } } return Lc; }
SqList Intersection(const SqList& La, const SqList& Lb) { SqList Lc; InitList(Lc); for (int i = 0; i < La.length; ++i) { if (LocElem(Lb, La.data[i]) != 0) { InsElem(Lc, La.data[i], Lc.length + 1); } } return Lc; }
|