Advertisement
Mitax

05.Decode_Radio_Frequencies

Feb 27th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _05.Decode_Radio_Frequencies
  5. {
  6. class DecodeRadioFreq
  7. {
  8. static void Main(string[] args)
  9. {
  10. var numbers = Console.ReadLine()
  11. .Split(' ', '.')
  12. .Select(int.Parse)
  13. .ToList();
  14.  
  15. for (int i = 0; i < numbers.Count; i++)
  16. {
  17. numbers.Remove(0);
  18. }
  19. var charRepresentation = new string[numbers.Count];
  20. var currentChar = ' ';
  21.  
  22. for (int i = 0, j = 1, k = 0; k < numbers.Count / 2; i += 2, j += 2, k++)
  23. {
  24. currentChar = (char)numbers[i];
  25. charRepresentation[k] = currentChar.ToString();
  26. currentChar = (char)numbers[j];
  27. charRepresentation[numbers.Count - 1 - k] = currentChar.ToString();
  28.  
  29. if (k == 0) //mid element
  30. {
  31. currentChar = (char)numbers.Last();
  32. charRepresentation[charRepresentation.Length / 2] = currentChar.ToString();
  33. }
  34. }
  35. Console.WriteLine(String.Join("",charRepresentation));
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement