#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int x;
int attempt = 0;
// Ввод числа
while (attempt < 3) {
cout << "Введите целое число: ";
if (cin >> x) break;
attempt++;
cerr << "Ошибка ввода (попытка " << attempt << "/3)\n";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
if (attempt == 3) {
cerr << "Ошибка: превышено число попыток!\n";
return 1;
}
// Системы счисления
cout << "DEC: " << dec << x
<< " HEX: " << showbase << hex << x
<< " OCT: " << oct << x
<< dec << noshowbase << '\n';
// Перестановка цифр
ostringstream oss;
oss << dec << x;
string s = oss.str();
bool negative = s[0] == '-';
if (negative) s.erase(0, 1);
reverse(s.begin(), s.end());
size_t pos = s.find_first_not_of('0');
s = (pos == string::npos) ? "0" : s.substr(pos);
if (negative && s != "0") s = "-" + s;
istringstream iss(s);
long long reversed;
if (!(iss >> reversed)) {
cerr << "Ошибка преобразования числа!\n";
return 1;
}
cout << "Перевёрнутое число: " << reversed << '\n';
return 0;
}