Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Enigma
- {
- class Program
- {
- static void Main()
- {
- string[] decimalValues = ReadData();
- List<string> binaryValues = new List<string>();
- StringBuilder sb = new StringBuilder();
- for (int currIndex = 0; currIndex < decimalValues.Length; currIndex++)
- {
- string currentValue = Convert.ToString(int.Parse(decimalValues[currIndex]), 2);
- currentValue = currentValue.PadLeft(8, '0');
- binaryValues.Add(currentValue);
- }
- for (int i = 0; i < binaryValues.Count; i++)
- {
- string currentBinary = binaryValues[i];
- if (i % 2 == 0)
- {
- for (int j = 0; j < currentBinary.Length; j++)
- {
- if (j % 2 != 0)
- {
- sb.Append(currentBinary[j]);
- }
- }
- }
- else
- {
- for (int j = 0; j < currentBinary.Length; j++)
- {
- if (j % 2 == 0)
- {
- sb.Append(currentBinary[j]);
- }
- }
- }
- }
- Console.WriteLine(sb.ToString());
- }
- public static string[] ReadData() => Console.ReadLine()
- .Split(new[] { ',', ' ' });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment