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.
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>//Complete the following function.voidcalculate_the_maximum(intn,intk){intand=0,or=0,xor=0;for(inti=1;i<=n;i++){for(intj=i+1;j<=n;j++){inttand=i&j,tor=i|j,txor=i^j;if((tand>and)&&(tand<k))and=tand;if((tor>or)&&(tor<k))or=tor;if((txor>xor)&&(txor<k))xor=txor;}}printf("%d\n%d\n%d\n",and,or,xor);}intmain(){intn,k;scanf("%d %d",&n,&k);calculate_the_maximum(n,k);return0;}
Cookie support is required to access HackerRank
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 →