This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2025-05-03 01:17:58 +03:00

33 lines
547 B
C++

#include <string>
class BinaryNumber
{
std::string str;
public:
BinaryNumber(const std::string& s = "0") {
str = s;
}
operator std::string() const {
return str;
}
const BinaryNumber& operator++() {
auto i = --str.end();
while (*i == '1' && i != str.begin()) {
*i = '0';
--i;
}
if (i == str.begin()) {
*i = '0';
str.insert(str.begin(), '1');
} else {
*i = '1';
}
return *this;
}
};