0
The concept is bit reversion ...to convert a number into reversed order of 32 bit unsigned integers
You will be given a variable list of unknown length, containing 32-bits unsigned integers. You are required to give as output a comma separated list, showing for each element in the list the integer you get by reversing bits in its binary representation. For example, if the list is 32768, 101200 and 262144, you are expected to give as output 65536, 181501952 and 8192. Integers in the list will be given one per line.
4 Respuestas
+ 2
You can share link to your code in progress, so we can try to work it out as you go 👇
https://www.sololearn.com/post/75089/?ref=app
+ 1
Hint:
Use std::vector as number container, it's a dynamic container.
https://en.cppreference.com/w/cpp/container/vector
Use std::bitset to work with a number. Swap bits from both edge, and get the unsigned int value using std::bitset::to_ulong() member function.
https://en.cppreference.com/w/cpp/utility/bitset
0
sorry i am not able share the code... but here's the idea what i have...
first step is obvious to convert given number into binary..
convert into a string
make it a 32bit long(add zeroes on left)
now starting from left multiplying each int(digit) with power of 2 and add to a variable and increase the power of 2 with each digit..
i guess that's the variable that keep accumulating is the answer..
this is the function part..
now the part for reading input... u can just store each input in a vector or array, then iterate through it replacing it with the above function's value... while printing u can print till last but two, followed by a "," and the last two values seperated with "and".