Advertisement
Guest User

Untitled

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