#include <cctype>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
class SumAlternatingSeries {
public:
SumAlternatingSeries() : ordinal_term(0) {}
private:
unsigned long long ordinal_term;
void check_value_type(string& str) {
if (str.empty()) {
str = "0";
return;
}
if (str.front() < 0 || !isdigit(str.front())) {
str = "0";
return;
}
while (str.front() == '0'
{
if (str.length() == 1 && str.front() == '0'
{
return;
}
str = str.erase(0, 1);
}
for (auto ch : str) {
if (ch < 0 || !isdigit(ch)) {
str = "0";
return;
}
}
}
friend istream& operator>>(istream& inp, SumAlternatingSeries& sas) {
string tmp;
getline(inp, tmp);
sas.check_value_type(tmp);
sas.ordinal_term = stoull(tmp);
return inp;
}
friend ostream& operator<<(ostream& out, const SumAlternatingSeries& sas) {
const auto ot = sas.ordinal_term;
if (!ot) {
return out << "Erroneous data!";
}
auto result = ot & 1 ? ot + 1 : ot;
if (~ot & 1) {
out.put('-'
;
}
return out << result;
}
};
int main() {
SumAlternatingSeries sas;
while (true) {
cout << ">>> ";
cin >> sas;
cout << "<<< ";
cout << sas << '\n';
}
}