Advertisement
Guest User

XOR

a guest
Jul 5th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 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 ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int b = 0, a = 0;
  14.             while (b != -1)
  15.             {
  16.                 Console.WriteLine("a: ");
  17.                 a = int.Parse(Console.ReadLine());
  18.                 Console.WriteLine("b: ");
  19.                 b = int.Parse(Console.ReadLine());
  20.                 string abinary = Convert.ToString(a, 2);
  21.                 string bbinary = Convert.ToString(b, 2);
  22.                 Console.WriteLine(string.Format("a: {0}", abinary));
  23.                  Console.WriteLine(string.Format("b: {0}", bbinary));
  24.                  int XOR = (a ^ b);
  25.                 Console.WriteLine("XOR: (int) {0}", XOR);
  26.                 Console.WriteLine("XOR (binary) {0}", Convert.ToString(XOR, 2));
  27.  
  28.             }
  29.             Console.ReadLine();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement