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.
voidcalculate_the_maximum(intn,intk){//Write your code here.inti=0,j=0,result[3],result_store[3],sample[n];for(i=1;i<=n;i++)sample[i]=i;for(i=0;i<=n;i++){for(j=i+1;j<=n;j++){if((sample[i]&sample[j])<k){result[0]=(sample[i]&sample[j]);}if((sample[i]|sample[j])<k){result[1]=(sample[i]|sample[j]);}if((sample[i]^sample[j])<k){result[2]=(sample[i]^sample[j]);}if(result[0]>result_store[0]){result_store[0]=result[0];}if(result[1]>result_store[1]){result_store[1]=result[1];}if(result[2]>result_store[2]){result_store[2]=result[2];}}}printf("%d\n",result_store[0]);printf("%d\n",result_store[1]);printf("%d\n",result_store[2]);}
On running the code, it gives strange error, while in my local compiler, it works fine.
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 →
my code
On running the code, it gives strange error, while in my local compiler, it works fine.