Advertisement
pochti_da

Untitled

Oct 5th, 2020
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <sys/stat.h>
  5. #include <fcntl.h>
  6. #include <stdint.h>
  7. #include <math.h>
  8.  
  9. int
  10. main(void)
  11. {
  12.     uint32_t n, s, w;
  13.     if (scanf("%u%u%u", &n, &s, &w) != 3) {
  14.         return 1;
  15.     }
  16.  
  17.     for (uint32_t curr = 0; curr < (1 << n); curr += s) {
  18.         uint32_t signed_curr = curr;
  19.         if (signed_curr & ((uint32_t)1 << (n - 1))) {
  20.             signed_curr ^= ((uint32_t)1 << (n - 1));
  21.             signed_curr *= -1;
  22.         }
  23.  
  24.         printf("|%*o|%*u|%*d|\n", w, curr, w, curr, w, signed_curr);
  25.     }
  26.  
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement