Advertisement
filashkov

Untitled

Oct 6th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include <string.h>
  10.  
  11. uint_least32_t w;
  12.  
  13. uint_least32_t
  14. safe_pow(uint_least32_t base, uint_least32_t deg)
  15. {
  16.     uint_least32_t result = 1;
  17.     while (deg--) {
  18.         result *= base;
  19.     }
  20.     return result;
  21. }
  22.  
  23. void
  24. set1(uint_least32_t *a)
  25. {
  26.     while (true) {
  27.         uint_least32_t t = *a;
  28.         *a |= 1;
  29.         *a <<= 1;
  30.         if (*a == t) {
  31.             break;
  32.         }
  33.     }
  34. }
  35.  
  36. void
  37. print_octal(uint_least32_t b)
  38. {
  39.     char s[34];
  40.     for (int i = 0; i < 34; i++) {
  41.         s[i] = '\0';
  42.     }
  43.     int index = 0;
  44.     while (b != 0) {
  45.         s[32 - 1 - index] = b % 8;
  46.         b /= 8;
  47.         index++
  48.     }
  49.     char *real_s = s + 32 - index;
  50.     printf("%s", real_s);
  51. }
  52.  
  53. void
  54. print_dec(uint_least32_t b)
  55. {
  56.     char s[34];
  57.     for (int i = 0; i < 34; i++) {
  58.         s[i] = '\0';
  59.     }
  60.     int index = 0;
  61.     while (b != 0) {
  62.         s[32 - 1 - index] = b % 10;
  63.         b /= 10;
  64.         index++
  65.     }
  66.     char *real_s = s + 32 - index;
  67.     for ()
  68.     printf("%s", real_s);
  69. }
  70.  
  71. void
  72. print_octal_o(uint_least32_t b)
  73. {
  74.     char s[34];
  75.     for (int i = 0; i < 34; i++) {
  76.         s[i] = '\0';
  77.     }
  78.     int index = 0;
  79.     while (b != 0) {
  80.         s[32 - 1 - index] = b % 8;
  81.         b /= 8;
  82.         index++
  83.     }
  84.     char *real_s = s + 32 - index;
  85.     printf("%s", real_s);
  86. }
  87.  
  88. uint32_t
  89. reads(char *s)
  90. {
  91.     uint32_t result = 0;
  92.     int n = strlen(s);
  93.     for (int i = n - 1; i >= 0; i--)
  94.     {
  95.         result += (s[i] - '0');
  96.         result *= 10;
  97.     }
  98.     return result;
  99. }
  100.  
  101.  
  102. int
  103. main(int argc, char **argv)
  104. {
  105.     char ss[32], nn[32], ww[32];
  106.     uint_least32_t n, s, answer = 0;
  107.     cout << (uint_least32_t)answer << endl;
  108.     scanf("%s%s%s", nn, ss, ww);
  109.     n = reads(nn);
  110.     s = reads(ss);
  111.     w = reads(ww);
  112.     uint_least32_t bound = safe_pow(2, n);
  113.     if (n == 32) {
  114.  
  115.     }
  116.     for ( ; answer < bound; answer++) {
  117.         print_
  118.     }
  119. }
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement