SHARE
TWEET

Untitled

Alx09 May 31st, 2020 828 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int f(int nr) {
  4.     int n = 0, i = 31, t = 0;
  5.     while ((nr >> i) == 0) i--;
  6.     while (i >= 0) {
  7.         n |= (((nr & (1 << i)) != 0 ) << t);
  8.         t++;
  9.         i--;
  10.     }
  11.     return n;
  12. }
  13. int main() {
  14.     int n;
  15.     printf("n= "); scanf("%d", &n);
  16.     printf("Numarul obtinuit prin oglindirea biitlor numarului %d este %d\n", n, f(n));
  17.     return 0;
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top