Advertisement
Rucard

Katy

Feb 27th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <sstream>
  2. #include <iostream>
  3. #include <stdio.h>
  4. #include <conio.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.    
  10.     int n;
  11.     scanf("%i",&n);
  12.     int *mas = new int[n];
  13.     for (int i = 0; i < n; i++) {
  14.         scanf("%i",&mas[i]);
  15.     }
  16.     unsigned short num = 0;
  17.  
  18.     for (int i = 0; i < n; i++) {
  19.         if (mas[i]%2 == 0) {
  20.             unsigned short num_1 = 1;
  21.             num_1 = (num_1 << (15 - i));
  22.             num = (num | num_1);
  23.         }
  24.     }
  25.    
  26.         for (int i = 0; i < n; i++) {
  27.             unsigned short num_2 = 1;
  28.             num_2 = (num_2 << (15 - i));
  29.             num_2 = num & num_2;
  30.             if (((num_2 << i) >> 15) == 1)
  31.                 printf("1");
  32.             else
  33.                 printf("0");
  34.         }
  35.         printf("\n");
  36.    
  37.     _getch();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement