archangelmihail

WeAllLoveBits

Dec 4th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace WeAllLoveBits
  8. {
  9.     class WeAllLoveBits
  10.     {
  11.         static void Main()
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int[] results = new int[n];
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 int number = int.Parse(Console.ReadLine());
  18.                 string start = Convert.ToString(number, 2);
  19.                 string point = "";
  20.                 string dpoint = "";
  21.                 for (int j = 0; j < start.Length; j++)
  22.                 {
  23.  
  24.                     dpoint += start[start.Length - j - 1];
  25.                     if (start[j] == '0')
  26.                     {
  27.                         point += '1';
  28.                     }
  29.                     else
  30.                     {
  31.                         point += '0';
  32.                     }
  33.                 }
  34.                
  35.                 int one = Convert.ToInt32(start, 2);
  36.                 int two = Convert.ToInt32(point, 2);
  37.                 int three = Convert.ToInt32(dpoint, 2);
  38.                
  39.                 results[i] = ((one ^ two) & three);
  40.                
  41.  
  42.             }
  43.             for (int i = 0; i < n; i++)
  44.             {
  45.                 Console.WriteLine(results[i]);
  46.             }
  47.            
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment