Advertisement
Danny_Berova

04.DeserializeString

Aug 1st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1.  
  2. namespace _04.DeserializeString
  3. {
  4.     using System;
  5.     using System.Collections.Generic;
  6.     using System.Linq;
  7.     using System.Text;
  8.  
  9.     public class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.             string line = Console.ReadLine();
  14.             StringBuilder output = new StringBuilder(new string(' ', 20));
  15.            
  16.             while (line != "end")
  17.             {
  18.                 string[] tokens = line
  19.                 .Split(new[] { ':', '/' },
  20.                 StringSplitOptions.RemoveEmptyEntries);
  21.  
  22.                 string symbol = tokens[0];
  23.                 int[] indexes = tokens.Skip(1).Select(int.Parse).ToArray();
  24.  
  25.                 for (int i = 0; i < indexes.Length; i++)
  26.                 {
  27.                     int indeX = indexes[i];
  28.                     if (indeX >= output.Length - 1)
  29.                     {
  30.                         output.Append(new string(' ', 20));
  31.                     }
  32.                     if (symbol.Length == 1)
  33.                     {
  34.                        
  35.                         output.Replace(" ", symbol, indeX, 1);
  36.                     }
  37.                 }
  38.  
  39.                 line = Console.ReadLine();
  40.             }
  41.  
  42.             Console.WriteLine(output.ToString());
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement