Bits Manipulation
Description
Discuss (6 comments)
Write a program to swap odd and even bits in an unsigned integer with as few instructions as possible
E.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc...
E.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc...
Input Specifications
Your program must take a single command line argument; the name of a file. It must then open the file and read out the input data. Each line will contain an integer number e.g.1234567 7654321 888
Output Specifications
Your output must consist of exactly same number of lines as input with the expected results to the standard output. Using the above example, the output should be:2222411 12109682 948
© CoderCharts - All Rights Reserved
| Type | Puzzle | Pass | 421 | Fail | 187 | ||
| Scoring | Language | Level | Novice | Points | 400 | ||
| Tags | bits, math | ||||||
Unit Tests
| Name | CPU Unit | Memory Unit |
|---|---|---|
test1 |
Confirm that you want to switch languages
Your current edits will be lost.
Confirm that you wish to load a previous submission
Your current edits will be lost.