Advertisement
stoychevamaria89

Untitled

Jun 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 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 BitExchange
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. string binaryN = Convert.ToString(n, 2).PadLeft(32, '0');
  15. var binaryArray = binaryN.ToCharArray();
  16. Array.Reverse(binaryArray);
  17. Console.WriteLine(binaryArray);
  18.  
  19. char temp = binaryArray[3];
  20. binaryArray[3] = binaryArray[24];
  21. binaryArray[24] = temp;
  22.  
  23. char temp2 = binaryArray[4];
  24. binaryArray[4] = binaryArray[25];
  25. binaryArray[25] = temp2;
  26.  
  27. char temp3 = binaryArray[5];
  28. binaryArray[5] = binaryArray[26];
  29. binaryArray[26] = temp3;
  30.  
  31. Array.Reverse(binaryArray);
  32. string result = new string(binaryArray);
  33. int finalResult = Convert.ToInt32(result, 2);
  34. Console.WriteLine(finalResult);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement