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){intiand=0,ior=0,ixor=0;intimax_and=0,imax_or=0,imax_xor=0;intii,ij;for(ii=1;ii<n;ii++){for(ij=ii+1;ij<=n;ij++){iand=ii&ij;ior=ii|ij;ixor=ii^ij;if(iand>imax_and&&iand<k)imax_and=iand;if(ior>imax_or&&ior<k)imax_or=ior;if(ixor>imax_xor&&ixor<k)imax_xor=ixor;}}printf("%d\n%d\n%d\n",imax_and,imax_or,imax_xor);}intmain(){intn,k;scanf("%d %d",&n,&k);calculate_the_maximum(n,k);return0;}
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →