We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
void calculate_the_maximum(int n, int k) {
int a, b;
int AND, OR, XOR;
int maxAND = 0;
int maxOR = 0;
int maxXOR = 0;
for (int i = 1; i < n; i++){
for (int j = i + 1; j <= n; j++){
a = i;
b = j;
AND = a & b;
OR = a | b;
XOR = a ^ b;
if (AND < k){
if (maxAND < AND){maxAND = AND;}
}
if (OR < k){
if (maxOR < OR){maxOR = OR;}
}
if (XOR < k){
if (maxXOR < XOR){maxXOR = XOR;}
}
}
}
printf("%d\n%d\n%d", maxAND, maxOR, maxXOR);
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →
void calculate_the_maximum(int n, int k) { int a, b; int AND, OR, XOR; int maxAND = 0; int maxOR = 0; int maxXOR = 0;
}
int main() { int n, k;
}