Skip to content

Commit

Permalink
...ah, fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaSyatov committed Nov 28, 2022
1 parent 5927e7d commit adb6c5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions src/tbitfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,18 @@ int TBitField::operator!=(const TBitField &bf) const // сравнение

TBitField TBitField::operator|(const TBitField &bf) // операция "или"
{
int maxBitLen = BitLen;

if (BitLen < bf.BitLen)
maxBitLen = bf.BitLen;

size_t i = 0;
TBitField tmp(maxBitLen);
TBitField tmp(std::max(BitLen, bf.BitLen));
for (; i < std::min(MemLen, bf.MemLen); i++)
tmp.pMem[i] = pMem[i] | bf.pMem[i];

if (MemLen < bf.MemLen)
for (; i < std::max(MemLen, bf.MemLen); i++)
for (; i < bf.MemLen; i++)
tmp.pMem[i] = bf.pMem[i];
else
for (; i < std::max(MemLen, bf.MemLen); i++)
for (; i < MemLen; i++)
tmp.pMem[i] = this->pMem[i];


return tmp;
}

Expand Down Expand Up @@ -194,8 +188,8 @@ istream &operator>>(istream &istr, TBitField &bf) // ввод
if (number < bf.GetLength() && (bf.GetBit(number) == 1))
{
bf.SetBit(number);
index--;
}
index--;
}
return istr;
}
Expand All @@ -205,5 +199,7 @@ ostream &operator<<(ostream &ostr, const TBitField &bf) // вывод
for (size_t i = 0; i < bf.GetLength(); i++)
if (bf.GetBit(i))
ostr << i << ", ";
else
ostr << 0 << ", ";
return ostr;
}
2 changes: 1 addition & 1 deletion src/tset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ istream &operator>>(istream &istr, TSet &s) // ввод
if (number < s.GetMaxPower() && (s.IsMember(number) == 0))
{
s.InsElem(number);
index--;
}
index--;
}
return istr;
}
Expand Down

0 comments on commit adb6c5e

Please sign in to comment.