You are viewing a single comment's thread. Return to all comments →
{ int max_and = 0, max_or = 0, max_xor = 0;
for (int a = 1; a <= n; a++) { for (int b = a + 1; b <= n; b++) { int and_val = a & b; int or_val = a | b; int xor_val = a ^ b; if (and_val > max_and && and_val < k) { max_and = and_val; } if (or_val > max_or && or_val < k) { max_or = or_val; } if (xor_val > max_xor && xor_val < k) { max_xor = xor_val; } } } printf("%d\n%d\n%d\n", max_and, max_or, max_xor);
}
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 →
{ int max_and = 0, max_or = 0, max_xor = 0;
}