Advertisement
bullit3189

String Explosion / Karate strings - String and Text Proccess

Feb 17th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _07StringExplosion
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string text = Console.ReadLine();
  11.  
  12. int strength = 0;
  13.  
  14. for (int i = 0; i < text.Length; i++)
  15. {
  16. char symbol = text[i];
  17.  
  18. if (symbol == '>')
  19. {
  20. char nextSymbol = text[i + 1];
  21. strength += int.Parse(nextSymbol.ToString());
  22. continue;
  23.  
  24. }
  25. if (strength>0)
  26. {
  27. text = text.Remove(i, 1);
  28. i--;
  29. strength--;
  30. }
  31. }
  32. Console.WriteLine(text);
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement