You are viewing a single comment's thread. Return to all comments →
void calculate_the_maximum(int n, int k) { int maxAnd = 0; int maxOr = 0; int maxXor = 0; for (int i=1; i<=n; i++) { for (int j=i+1; j<=n; j++) { if (((i&j) > maxAnd) && ((i&j) < k)) { maxAnd = i&j; } if (((i|j) > maxOr) && ((i|j) < k)) { maxOr = i|j; } if (((i^j) > maxXor) && ((i^j) < k)) { maxXor = i^j; } } } printf("%d\n%d\n%d\n", maxAnd, maxOr, maxXor); }
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 →