paskal06

Untitled

Jul 30th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 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 PlaceHolders
  8. {
  9.     class Program
  10.     {
  11.         public static List<string> cells = new List<string>();
  12.        
  13.         static void Main(string[] args)
  14.         {
  15.             string input = Console.ReadLine();
  16.             while(input != "end")
  17.             {
  18.                 string[] inputToken = input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
  19.                 List<char> sentenceBuild = inputToken[0].ToList();
  20.                 string[] WordList = inputToken[1].Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
  21.                 for (int i = 0; i < sentenceBuild.Count; i++)
  22.                 {
  23.                     if (sentenceBuild[i] == '{' && sentenceBuild[i + 2] == '}')
  24.                         {
  25.                             int index = int.Parse(sentenceBuild[i + 1].ToString());
  26.                         index = Math.Abs(index);
  27.                             sentenceBuild.RemoveRange(i, 3);
  28.  
  29.                             List<char> entry = WordList[index].ToList();
  30.                             entry.Reverse();
  31.                             foreach (var letter in entry)
  32.                             {
  33.                                 sentenceBuild.Insert(i, letter);
  34.                             }
  35.                         }
  36.                    
  37.                 }
  38.                
  39.                 foreach(var letter in sentenceBuild)
  40.                 {
  41.                     Console.Write(letter);
  42.                 }
  43.                 Console.WriteLine();
  44.                 input = Console.ReadLine();
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment