Using hexadecimal conversion can be realized, the first turn in binary decimal, again from the decimal 0 to binary, decimal value by the binary switch.
CodePudding user response:
int main () { Unsigned char arr [256] {0}. Unsigned char x=0 xd; for (int i=0; I & lt; 255; I++) { Unsigned int b=I & amp; x; Arr [b]=1; } for (int i=0; I & lt; 256; I++) { If (arr [I]) Printf (" % 2 x \ r \ n ", I); } return 0; }
CodePudding user response:
Write two functions: two to hexadecimal decimal, decimal turn two to hex, then call these two functions can be realized.
CodePudding user response:
The original binary string without length? ! 1, 10000 to destroy earth day can run out the result?
CodePudding user response:
If the input digits must be, and the relatively small, can take advantage of the method on the second floor of the If the input digits can be quite large, the 0 out first, and then only 1, look at a few, then add up from 0 to go, is to produce the red on the number of these, you then can be put back to the previous 0, this should be the safest, pay attention to the insertion technique
CodePudding user response:
I think you all understand the wrong... The title of the original poster is string operation problems
# include & lt; iostream> # include & lt; Set> using namespace std; Set Sset; Void traversestr (string STR) { Sset. Insert (STR); for (int i=0; I & lt; 8; + + I) { If (STR [I]=='1') { Char c=STR [I]; STR [I]='0'; Traversestr (STR); STR [I]=c; } } }
Bool checkStr (string STR) { If (STR) length ()! { =8)Cout & lt; <"Input length not match" & lt; return false; } for (int i=0; I & lt; 8; + + I) { If (STR [I]!='0' & amp; & STR [I]!='1') { Cout & lt; <"Input data not available" & lt; return false; } } return true; }
Int main () { String STR. Do { Cin. The clear (); Cin & gt;> STR; }while(! CheckStr (STR)); Traversestr (STR); Set : : iterator it=sset. The begin (); For (; it !=sset. End (); + + it) { Cout & lt; <* it & lt; }; return 0; }