Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace BitSwapper
- {
- class BitSwapper
- {
- static void Main()
- {
- uint first = uint.Parse(Console.ReadLine());
- uint second = uint.Parse(Console.ReadLine());
- uint third = uint.Parse(Console.ReadLine());
- uint fourth = uint.Parse(Console.ReadLine());
- string[] binaries = new string[4];
- binaries[0] = Convert.ToString(first, 2).PadLeft(32, '0');
- binaries[1] = Convert.ToString(second, 2).PadLeft(32, '0');
- binaries[2] = Convert.ToString(third, 2).PadLeft(32, '0');
- binaries[3] = Convert.ToString(fourth, 2).PadLeft(32, '0');
- List<List<string>> numsChunks = new List<List<string>>();
- for (int i = 0; i < 4; i++)
- {
- List<string> tempNum = new List<string>();
- for (int j = 0, k=0; j < 8; j++,k+=4)
- {
- string temp = binaries[i][k].ToString() +
- binaries[i][k + 1].ToString() + binaries[i][k + 2].ToString() +
- binaries[i][k + 3].ToString();
- tempNum.Add(temp);
- }
- numsChunks.Add(tempNum);
- }
- while (true)
- {
- string firstPart = Console.ReadLine();
- if (firstPart=="End")
- {
- break;
- }
- string secondPart = Console.ReadLine();
- int firstIndex = Convert.ToInt32(firstPart[0].ToString());
- int secondIndex = Convert.ToInt32(secondPart[0].ToString());
- int firstChunk = Convert.ToInt32(firstPart[2].ToString());
- int secondChunk = Convert.ToInt32(secondPart[2].ToString());
- string firstExtract = numsChunks[firstIndex][7 - firstChunk];
- string secondExtract = numsChunks[secondIndex][7 - secondChunk];
- numsChunks[firstIndex][7 - firstChunk] = secondExtract;
- numsChunks[secondIndex][7 - secondChunk] = firstExtract;
- }
- foreach (var vari in numsChunks)
- {
- string[] nums=new string[8];
- int i = 0;
- foreach (var str in vari)
- {
- nums[i] = str;
- i++;
- }
- string final = string.Join("", nums);
- Console.WriteLine(Convert.ToUInt32(final,2));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment