Advertisement
dinko_dt

Untitled

Mar 15th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _07._String_Explosion
  7. {
  8. class String_Explosion
  9. {
  10. static void Main()
  11. {
  12.  
  13. string text = Console.ReadLine();
  14.  
  15. string[] spliittedInput = text.Split(">", StringSplitOptions.RemoveEmptyEntries);
  16.  
  17. string result = spliittedInput[0];
  18. int remainingPower = 0;
  19. for (int i = 1; i < spliittedInput.Length; i++)
  20. {
  21. result += ">";
  22. int power = int.Parse(spliittedInput[i][0].ToString()) + remainingPower;
  23. if (power > spliittedInput[i].Length)
  24. {
  25. remainingPower = power - spliittedInput[i].Length;
  26. }
  27. else
  28. {
  29. result += spliittedInput[i].Substring(power);
  30. }
  31.  
  32. }
  33. Console.WriteLine(result);
  34.  
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement