啊 烦人的C++ 谁能帮我编个程序啊
来源:百度知道 编辑:UC知道 时间:2024/06/01 02:09:08
集合
#include <bitset>
using namespace std;
class Set500
{
public:
bitset<500> set;
bool operator[](int i){return set[i];}
Set500 operator&(Set500& another); //交
Set500 operator|(Set500& another); //并
Set500 operator-(Set500& another); //差
bool operator>(Set500& another); //大于
}
Set500 Set500::operator&(Set500& another)
{
Set500 result;
for(int i=1;i<500;i++)
result.set(i,(*this)[i] && another[i]);
return result;
}
Set500 Set500::operator|(Set500& another)
{
Set500 result;
for(int i=1;i<500;i++)
result.set(i,(*this)[i] || another[i]);
return result;
}
Set500 Set500::operator-(Set500& another)
{
Set500 result;
for(int i=1;i<500;i++)
result.set(i,(*this)[i]?(*this)[i]&&another[i]: false);
return result;
}
bool Set500::operator>