Advertisement
nikolapetkov824

StringExplosion

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