Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace WeAllLoveBits
- {
- class WeAllLoveBits
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- uint[] inputNums = new uint[n];
- for (int i = 0; i < n; i++)
- {
- inputNums[i] = uint.Parse(Console.ReadLine());
- }
- for (int i = 0; i < inputNums.Length; i++)
- {
- string tempNumBinary = Convert.ToString(inputNums[i], 2);
- //
- string[] inverted = new string[tempNumBinary.Length];
- for (int j = 0; j < tempNumBinary.Length; j++)
- {
- if (tempNumBinary[j]=='0')
- {
- inverted[j] = "1";
- }
- else
- {
- inverted[j] = "0";
- }
- }
- int invertedInt = Convert.ToInt32(string.Join("", inverted),2);
- //
- string[] reversedArray = new string[tempNumBinary.Length];
- for (int k = tempNumBinary.Length-1, z=0; k >=0; k--,z++)
- {
- reversedArray[z] = tempNumBinary[k].ToString();
- }
- int reversed = Convert.ToInt32(string.Join("", reversedArray), 2);
- //
- long result = (inputNums[i] ^ invertedInt) & reversed;
- Console.WriteLine(result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment