Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int f(int nr) {
- int n = 0, i = 31, t = 0;
- while ((nr >> i) == 0) i--;
- while (i >= 0) {
- n |= (((nr & (1 << i)) != 0 ) << t);
- t++;
- i--;
- }
- return n;
- }
- int main() {
- int n;
- printf("n= "); scanf("%d", &n);
- printf("Numarul obtinuit prin oglindirea biitlor numarului %d este %d\n", n, f(n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement