Home > Back-end >  C using bitwise operator to judge whether to 2 cubic multiples
C using bitwise operator to judge whether to 2 cubic multiples

Time:09-26

Input a and b, whether b for a power of 2 multiple

For example:

Enter 2 36

Said the 2 to the power of 2, and determine whether 36 for the 2 to the power of 2 multiple

Enter 4 496

Say 2 4 times, and determine whether 496 for 4 power of 2 multiple

Hypothesis 2 a power for p

If b is a power of 2 multiple of, the output is twice as large as the p b

Otherwise the output b in multiples of p

Need to use bitwise operator

CodePudding user response:

If (b & amp; (1 & lt; The else puts (" b is a multiple of p ");
  • Related