You are viewing a single comment's thread. Return to all comments →
a bit verbose in the inner cycle but it works;
void calculate_the_maximum(int n, int k) { //Write your code here. int tempAnd = 0; int tempOr = 0; int tempXor = 0; for (int i=1; i tempAnd) tempAnd = (i & j); if (((i | j) < k) && (i | j) > tempOr) tempOr = (i | j); if (((i ^ j) < k) && (i ^ j) > tempXor) tempXor = (i ^ j); } } } printf("%d\n%d\n%d\n", tempAnd, tempOr, tempXor); }
void calculate_the_maximum(int n, int k) { //Write your code here. int tempAnd = 0; int tempOr = 0; int tempXor = 0;
for (int i=1; i tempAnd) tempAnd = (i & j); if (((i | j) < k) && (i | j) > tempOr) tempOr = (i | j); if (((i ^ j) < k) && (i ^ j) > tempXor) tempXor = (i ^ j); } } } printf("%d\n%d\n%d\n", tempAnd, tempOr, tempXor); }
Seems like cookies are disabled on this browser, please enable them to open this website
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →
a bit verbose in the inner cycle but it works;