Okay. Solve the problem first. The page cannot be displayed.
The damn OJ doesn't know why it suddenly cannot be opened =-= I forgot the question.
This topic has been written in the beginning of Uruguay-Columbia.
Tomorrow is wrong. It should be today. I don't know when to sleep. =-=
Post the operation requirements and explanations for bitwise operations -------- I seem to have forgotten orz
Bitwise operations are binary operations. In system software, binary bitwise is often required. The C language provides six operations
Operator. These operators can only be used for integer operands, that is, they can only be used for signed or unsigned char, short, Int, and long types.
List of bitwise operators provided by C language:
Operator description
& Bitwise AND if the two corresponding binary bits are both 1, The result value of this bit is 1, otherwise it is 0
| If one of the bitwise OR Two corresponding binary bits is 1, The result value of this bit is 1.
^ Bitwise OR 0 if the two binary values involved in the operation are the same; otherwise, 1
~ Reverse retrieval ~ It is a unary operator used to reverse a binary number by bit. It is about to change 0 to 1 and Change 1 to 0.
<Left shift is used to shift all the binary bits of a number to N places left, and 0 to the right
> Shift right: shifts the binary digits of a number N places to the right, and moves them to the low position on the right to be discarded. For the unsigned number, add 0 to the high position.
// The Purple is the most conspicuous
Question link I cannot provide for the moment = I will be able to make up tomorrow
1 # include <iostream> 2 using namespace STD; 3 4 int main () 5 {6 unsigned long num; // here, the unsigned long can meet the data requirements of the question. 7 while (CIN> num) 8 {9 int Len = 0; 10 unsigned long temp = num; 11 while (temp) // obtain the sequence length after converting num-> to a binary number, for example, 5-> 101, that is, Len = 3 12 {13 temp> = 1; 14 Len ++; 15} 16 temp = num; 17 for (INT I = 0; I <Len; I ++) 18 {19 cout <temp; 20 if (temp & (1ll <(LEN-1) // here (1ll <(len-1 )) is from the same length of the binary sequence high to low is 1 start enumeration 21 {// If & successful then represents the num binary sequence leftmost (that is, the highest bit) is 1, then 1 is moved to the last 22 temp = (temp ^ (1ll <(LEN-1) <1) | 1; 23} // It mainly utilizes the properties of ^ and <shifts the number of binary values to the left and uses 0 to fill the value with 1 | then it is 1 for 24 else 25 {26 temp = temp <1; // here, it indicates that the leftmost digit is 0, so direct <27} 28 if (I <len-1) 29 {30 cout <""; 31} 32 else 33 {34 cout <Endl; 35} 36} 37} 38 return 0; 39}
View code
Recently, I like to use C ++'s CIN cout to write smoothly.
Today:
I am new to XXX, the closest friend of yesterday.
The most familiar stranger