格物学
高中知识点
.jpg)
#include
#include
using namespace std;
template
class MySet
{
public:
MySet();
MySet(int s, const Type a[]);
MySet(const MySet &o);
void Empty();
bool IsEmpty() const;
bool IsMemberOf(const Type &m) const;
void Add(const Type &m);
Type Sub();
bool IsEqual(const MySet &o) const;
MySet operator&(const MySet &o);
MySet operator|(const MySet &o);
void Print();
private:
Type element[1
int count;
};
template
MySet::MySet() : count(0)
{
}
template
MySet::MySet(int s, const Type a[]) : count(s)
{
for (int i = 0;
i < s;
++i)
element[i] = a[i];
}
template ::MySet(const MySet &o)
{
count = o.count;
for (int i = 0;
i < count;
++i)
element[i] t[i];
}
template
void MySet::Empty()
{
count = 0
}
template ::IsEmp
{
return (count == 0);
}
templname Type>
bool MySet::IsEqual(const MySet &o) const
{
if ((count !
= o.count)
|| (IsEmp
|| (!
IsEm
return fals
for (int i =
{
if (element[i] !
= o.element[i])
retur
}
return true;
}
template
bool MySet::IsMemberOf(const Type &m) const
{
if (IsEmpty())
return fa
for (int i = 0;
i < count;
++i)
{
if (element[i] == m)
return true;
}
return false;
}
pename Type>
void MySet::Add(c
{
if (++count > 100)
return;
element[count - 1]
}
template
Type MySet::Sub()
{
if (IsEmpty())
return 0;
Type temp = element[count];
--count;
return temp;
}
template
MySet MySet::operator&(const MySet &o)
{
MySet inset;
if (IsEmpty() || o.IsEmpty())
return inset;
for (int i = 0;
i < count;
++i)
{
for (int j = 0;
j < o.count;
++j)
if (element[i] == o.element[j] && !
inset.IsMemberOf(o.element[j]))
inset.Add(element[i]);
}
return inset;
}
template
MySet MySet::operator|(const MySet &o)
{
MySet unset(count, element);
if (!
IsEmpty() && o.IsEmpty())
return unset;
if (IsEmpty() && !
o.IsEmpty())
return MySet(o);
for (int i = 0;
i < count;
++i)
{
for (int j = 0;
j < o.count;
++j)
if (element[i] !
= o.element[j] && !
unset.IsMemberOf(o.element[j]))
unset.Add(o.element[j]);
}
return unset;
}
template
void MySet::Print()
{
for (int i = 0;
i < count;
++i)
cout << element[i] << ' ';
cout << endl;
}
int main()
{
int ia[7] = { 1, 2, 3, 4, 5, 6, 7 };
MySet a, b(7, ia);
a.Add(6);
a.Add(7);
a.Add(8);
a.Add(9);
a.Print();
b.Print();
MySet c = a | b;
MySet d = a & b;
c.Print();
d.Print();
MySet str;
str.Add("Hello");
str.Add("World!
");
str.Print();
return 0;
}
内容来自网友回答
数学中的交集和并集有什么明显区别
最好说详细一点 ,我最近病了没回校上课
并集和交集的举例
交集及其运算
设集合,集合.若中恰含有一个整数,则实数的取值范围是(??)A.B.C.D.
设集合,集合.若中恰含有一个整数,则实数的取值范围是( )A.B.C.D.
已知集合U=﹛1,2,3,.,100﹜,A=﹛被3整除的数﹜,B=﹛被2整除的数...
已知集合U=﹛1,2,3,.,100﹜,A=﹛被3整除的数﹜,B=﹛被2整除的数﹜,则A∪B中的元素个数为
若A={x|x+1>0},B={x|x-3<0},则A∩B?.
若A={x|x+1>0},B={x|x-3<0},则A∩B .
如果集合P={x|x2-x=0},集合Q={x|x2+x=0},那么P∩Q等于(...
如果集合P={x|x2-x=0},集合Q={x|x2+x=0},那么P∩Q等于( )
A.0
B.{0}
C.?
D.{-1,0,1}
已知集合U=﹛1,2,3,....,100﹜,A=﹛被3整除的数﹜,B=﹛被2整除的数﹜,则A∪B中的元素个数为
交集及其运算
已知集合A={x|-1<x≤4},集合B={?x|2<x≤5},则A∩B=?.
已知集合A={x|-1<x≤4},集合B={ x|2<x≤5},则A∩B= .
已知集合A={x|x<0},B={x|-1<x<1},则A∩B=(?)?A.{x...
已知集合A={x|x<0},B={x|-1<x<1},则A∩B=( )
A.{x|x<-1}
B.{x|-1<x<0}
C.{x|0<x<1}
D.{x|x<1}
已知集合A={1,3,5,7,9},B={0,3,6,9,12},则A∩?NB=...
已知集合A={1,3,5,7,9},B={0,3,6,9,12},则A∩?NB= .
设全集I是实数集R,M={x|-2≤x≤2},N={x|x<1},则CIM∩N等...
设全集I是实数集R,M={x|-2≤x≤2},N={x|x<1},则CIM∩N等于( )
A.{x|x<-2}
B.{x|-2<x<1}
C.{x|x<1}
D.{x|-2≤x<1}