Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. namespace Placeholder
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7.  
  8. public class Program
  9. {
  10. public static void Main()
  11. {
  12. string inputLine = Console.ReadLine();
  13.  
  14. while (inputLine != "end")
  15. {
  16. string[] tokens = inputLine
  17. .Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
  18. string sentence = tokens[0];
  19. string[] placeholders = tokens[1]
  20. .Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
  21.  
  22. for (int i = 0; i < placeholders.Length; i++)
  23. {
  24. string currentPlaceholder = "{" + i + "}";
  25. sentence = sentence.Replace(currentPlaceholder, placeholders[i]);
  26. }
  27.  
  28. Console.WriteLine(sentence);
  29.  
  30. inputLine = Console.ReadLine();
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement