Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define bits(x) sizeof(x) * 8
- void showBits(unsigned x) {
- for (int i = bits(x) - 1; i >= 0; i--) {
- printf("%d", 1 & (x >> i));
- }
- puts("");
- }
- unsigned rightrot(unsigned x, unsigned n) {
- return (x >> n) | (x << (bits(x) - n));
- }
- int main() {
- unsigned x, n;
- printf("x="); scanf("%u", &x);
- printf("n="); scanf("%u", &n);
- showBits(x);
- showBits(rightrot(x, n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement