SHARE
TWEET

Untitled

a guest Mar 24th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Created by syh on 19-3-14.
  3. //
  4.  
  5. #include <stdio.h>
  6.  
  7. void f(int x) {
  8.     int i;
  9.     for (i = 0; i < 32; i++) printf("%d", (x >> (31 - i)) & 1);
  10.     printf("   ");
  11.  
  12.     //x = _______________________;
  13.     x = x & (x + 1);
  14.  
  15.     for (i = 0; i < 32; i++) printf("%d", (x >> (31 - i)) & 1);
  16.     printf("\n");
  17. }
  18.  
  19. int main() {
  20.     f(103); // binary: 1100111
  21.     f(12); // binary: 1100
  22.     return 0;
  23. }
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