You are viewing a single comment's thread. Return to all comments →
//Complete the following function.
void calculate_the_maximum(int n, int k) { int temp = 0; int maxAND =0; int maxOR =0; int maxEXOR =0;
for(int i = 1; i < n; i++) { for(int j = (i +1); j <= n; j++) {
temp = i & j; maxAND = ((temp > maxAND) && (temp < k)) ? temp : maxAND; temp = i | j; maxOR = ((temp > maxOR) && (temp < k)) ? temp : maxOR; temp = i ^ j; maxEXOR = ((temp > maxEXOR) && (temp < k)) ? temp : maxEXOR; }
} printf("%d\n", maxAND); printf("%d\n", maxOR); printf("%d\n", maxEXOR); }
int main() { int n, k;
scanf("%d %d", &n, &k); calculate_the_maximum(n, k); return 0;
}
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 →
include
include
include
include
//Complete the following function.
void calculate_the_maximum(int n, int k) { int temp = 0; int maxAND =0; int maxOR =0; int maxEXOR =0;
for(int i = 1; i < n; i++) { for(int j = (i +1); j <= n; j++) {
} printf("%d\n", maxAND); printf("%d\n", maxOR); printf("%d\n", maxEXOR); }
int main() { int n, k;
}