Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace String_Explosion
- {
- class Program
- {
- static void Main(string[] args)
- {
- StringBuilder input = new StringBuilder();
- input.Append(Console.ReadLine());
- int strength = 0;
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i] == '>')
- {
- strength += int.Parse(input[i + 1].ToString());
- if (char.IsLetterOrDigit(input[i + 1]))
- {
- for (int j = i + 1; j < i + 1 + strength; j++)
- {
- if (strength > input.Length - j - 1)
- {
- input.Remove(j, input.Length - j);
- break;
- }
- if (input[j] != '>')
- {
- input.Remove(j, 1);
- strength -= 1;
- j--;
- }
- }
- }
- }
- }
- Console.WriteLine(input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment