Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <bitset>
- using namespace std;
- bool && (bool cond1, bool cond2) {
- if (!cond1) {
- return false;
- }
- else {
- return true;
- }
- }
- int & (bool cond1, bool cond2) { //тут пришлось сделать тип возвращаемой функции int, т.к. тип возвращаемого значения при перегрузке функций менять нельзя
- if (!cond1) {
- if (!cond2) {
- return false;
- }
- else {
- return false;
- }
- }
- if (cond1) {
- if (!cond2) {
- return false;
- }
- else {
- return true;
- }
- }
- }
- int & (int num_one, int num_two) {
- bitset <8> number_one(num_one);
- //cout << number_one.to_ulong() << " = " << number_one << endl;
- bitset <8> number_two(num_two);
- //cout << number_two.to_ulong() << " = " << number_two << endl;
- bitset <8> number;
- for (int i = 7; i >= 0; i--) {
- if (number_one[i] == 1) {
- if (number_two[i] == 1) {
- number[i] = 1;
- }
- else {
- number[i] = 0;
- }
- }
- else {
- if (number_two[i] == 1) {
- number[i] = 0;
- }
- else {
- number[i] = 0;
- }
- }
- }
- //cout << endl;
- //cout << number.to_ulong() << " = " << number;
- return number.to_ulong();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement