#include #include #include uint16_t reverse(uint16_t x) { x = (x & 0xFF) << 8 | (x & 0xFF00) >> 8; return x; } void print_in_hex(uint16_t num) { printf("%04X ", num); } void print_in_binary(uint16_t num) { for (int i = 15; i >= 0; i--) { printf("%d", (num >> i) & 1); if (i % 8 == 0) printf(" "); } } int main() { setlocale(LC_ALL, "Russian"); uint16_t operand1, operand2; char symbol; scanf("%hu %c %hu", &operand1, &symbol, &operand2); operand1 = reverse(operand1); operand2 = reverse(operand2); uint16_t result; switch (symbol) { case '&': result = operand1 & operand2; break; case '|': result = operand1 | operand2; break; case '^': result = operand1 ^ operand2; break; default: printf("Неверный оператор\n"); return 1; } printf("\nРезультат: "); print_in_hex(operand1); printf("%c ", symbol); print_in_hex(operand2); printf("= "); print_in_binary(operand1); printf("%c ", symbol); print_in_binary(operand2); printf("= "); print_in_binary(result); printf("\n"); system("pause"); return 0; }