Check out the following api's for easy converting to binary and to strings :
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/[
^]
http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/[
^]
Now how go about this :
- user enters a number, this number is the maximum number, you only want numbers that are binary symetrical below that number.
- now you need a loop where you will start with say i and initialise it to 1
- convert i to a binary string using above api
- copy the result binary string in another string, this string must be big
- keep appending to this string from the first binary string, but from the back of the string to the beginning. You now have a symetrical string
- convert it to a number.
- if the number is bigger than what the user enters, loop should stop, otherwise print the number and binary representation.
This should get you started with enough information to get the job done I think.