Guest User

Untitled

a guest
Nov 29th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication2
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. var input = Convert.ToString('a', 2);
  13. var key = Convert.ToString('b', 2);
  14. int result = 0;
  15.  
  16. for (int i = 0; i < input.Length; i++)
  17. {
  18. result += (int) Math.Pow(input[i] != key[i] ? 1 : 0, i);
  19. }
  20.  
  21. Console.WriteLine("{1} xor {2} = {3} = {1}", Convert.ToChar(result), input, key, result);
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment