You are viewing a single comment's thread. Return to all comments →
Little nooby, but otherwise working:
void calculate_the_maximum(int n, int k) { int max_and = 0; int max_or = 0; int max_xor = 0; for(int i=1;i<=n;i++) { for(int j=i+1;j<=n; j++) { int and=j&i; int or=j|i; int xor=j^i; if(and>max_and && and<k) {max_and = and;} if(or>max_or && or<k) {max_or = or;} if(xor>max_xor && xor<k) {max_xor = xor;} } } printf("%d\n%d\n%d", 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 →
Little nooby, but otherwise working: