Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
46 строки
1013 B
C++
46 строки
1013 B
C++
#include <iostream>
|
|
#include <iomanip>
|
|
#include "lab04.h"
|
|
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
uint8_t singleByte = 0xAB;
|
|
uint8_t byteArray[] = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 };
|
|
|
|
cout << "Print in Hex:" << endl;
|
|
print_in_hex(singleByte);
|
|
|
|
cout << endl;
|
|
print_in_hex(byteArray, sizeof(byteArray));
|
|
|
|
cout << "\nPrint in Binary:" << endl;
|
|
print_in_binary(singleByte);
|
|
cout << endl;
|
|
print_in_binary(byteArray, sizeof(byteArray));
|
|
|
|
return 0;
|
|
}
|
|
|
|
int main_calc(){
|
|
uint16_t operand1, operand2;
|
|
char operation;
|
|
|
|
cout << "Enter the first operand (in hexadecimal): ";
|
|
cin >> std::hex >> operand1;
|
|
|
|
cout << "Enter the bitwise operation (&, |, or ^): ";
|
|
cin >> operation;
|
|
|
|
cout << "Enter the second operand (in hexadecimal): ";
|
|
cin >> std::hex >> operand2;
|
|
|
|
uint16_t result = perform_bitwise_operation(operand1, operation, operand2);
|
|
|
|
cout << "\nCalculation Result:" << endl;
|
|
print_calculation(result);
|
|
|
|
return 0;
|
|
}
|