CodePudding user response:
Is a simple mold and remainder? Turn the binary and decimal?If the former, with the operation, namely and 1 & amp; Operation
For example,
Int main () {
Int a=5;
The remainder of a printf (" % 2 d mould for % d \ n ", a, a& 1);//a and 1 do & amp; Computing is a model 2 remainders
return 0;
}
If the former, the decimal base 2, then step shift more
For example,
Void tobinary (int n) {
Int a=n& 1;/more than 2 o/a
If (n> 1) {
Tobinary (n> 1);//moves to the right one is divided by 2
}
Printf (" % d ", a);//print binary
}
Int main () {
Tobinary (5);//print 5 2 hexadecimal
return 0;
}
The above code is not a division and modulus, but they all get the same effect