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
cmc/contests/2contest/4.cpp
T
2025-04-13 21:48:15 +03:00

29 lines
547 B
C++

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