Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

32 строки
766 B
C++

#include <iostream>
#include <iomanip>
#include <bitset>
using namespace std;
int main() {
uint16_t operand1, operand2;
char operation;
cout << "Enter first operand: ";
cin >> operand1;
cout << "Enter operation (&, |, ^): ";
cin >> operation;
cout << "Enter second operand: ";
cin >> operand2;
uint16_t result = 0;
if (operation == '&') result = operand1 & operand2;
else if (operation == '|') result = operand1 | operand2;
else if (operation == '^') result = operand1 ^ operand2;
else {
cout << "Invalid operation" << endl;
return 1;
}
cout << "Hexadecimal: " << hex << setw(4) << setfill('0') << result << endl;
cout << "Binary: " << bitset<16>(result) << endl;
return 0;
}