You are viewing a single comment's thread. Return to all comments →
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> //Complete the following function. #define filter(a,b) ((a)<(b) ? a:0) #define max(a,b) ((a)>(b) ? a:b) void calculate_the_maximum(int n, int k) { //Write your code here. int maxand = 0; int maxor = 0; int maxxor = 0; for (int i = 1; i < n; i++) { for (int j = i + 1; j < n + 1; j++) { maxand = max(filter(i&j, k), maxand); maxor = max(filter(i|j, k), maxor); maxxor = max(filter(i^j, k), maxxor); } } printf("%d\n%d\n%d\n", maxand, maxor, maxxor); } 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 →