Advertisement
Necto

get bits of int

Sep 29th, 2022
699
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n;
  6.     scanf("%d", &n);
  7.     for(int j = 0; j < 256; ++j) {
  8.         for(int i = 31; i >= 0; --i) {
  9.             int c = (j & ( 1 << i )) >> i;
  10.             printf("%d", c);
  11.         }
  12.         printf("\n");
  13.     }
  14.     return 0;
  15. }
  16.  
Advertisement
Comments
  • itajara
    64 days
    # text 0.13 KB | 0 0
    1. Technically that is just plain Kernighan and Ritchie. That's what they made America out of, long ago- all of it- from C to shining C.
Add Comment
Please, Sign In to add comment
Advertisement