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){//Write your code here.intmaxand=0;intmaxor=0;intmaxxor=0;for(inti=1;i<=n;i++){for(intj=i+1;j<=n;j++){intcand=i&j;intcor=i|j;intcxor=i^j;if(maxand<cand&&cand<k){maxand=cand;}if(maxor<cor&&cor<k){maxor=cor;}if(maxxor<cxor&&cxor<k){maxxor=cxor;}}}printf("%d \n%d \n%d \n",maxand,maxor,maxxor);}intmain(){intn,k;scanf("%d %d",&n,&k);calculate_the_maximum(n,k);}
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →