StoneHaos

145

Nov 3rd, 2019
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //145
  2. #include <cstdio>
  3.  
  4. char out[12];
  5.  
  6. int main(void) {
  7.     freopen("input.txt", "r", stdin);
  8.     freopen("output.txt", "w", stdout);
  9.  
  10.     char a[7], b[7], x = 0, y = 0;
  11.     scanf("%s%s", a, b);
  12.     for (int i = 0; a[i] != 0; ++ i) {
  13.         x += a[i] - 0x30;
  14.         x <<= 1;
  15.     }
  16.     x >>= 1;
  17.     for (int i = 0; b[i] != 0; ++ i) {
  18.         y += b[i] - 0x30;
  19.         y <<= 1;
  20.     }
  21.     y >>= 1;
  22.     x += y;
  23.     if (x == 0) {
  24.         printf("0\n");
  25.         return 0;
  26.     }
  27.     for (y = 10; x != 0; -- y, x >>= 1)
  28.         out[y] = x % 2 + 0x30;
  29.     printf("%s\n", out + y + 1);
  30.     return 0;
  31. }
RAW Paste Data