Advertisement
daxtera

Untitled

Mar 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace _07._String_Explosion
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string field = Console.ReadLine();
  11. List<char> elementsOfField = new List<char>();
  12.  
  13. int explosionRadius = 0;
  14.  
  15. for (int i = 0; i < field.Length; i++)
  16. {
  17. elementsOfField.Add(field[i]);
  18. }
  19.  
  20.  
  21.  
  22. for (int j = 0; j < elementsOfField.Count; j++)
  23. {
  24. if (elementsOfField[j] == '>')
  25. {
  26. double radius = char.GetNumericValue(elementsOfField[j + 1]);
  27.  
  28. for (int k = j; k < elementsOfField[(int)(radius + explosionRadius)]; k++)
  29. {
  30. j++;
  31. explosionRadius = 0;
  32. if (elementsOfField[k + 1] != '>')
  33. {
  34. elementsOfField.RemoveAt(k + 1);
  35. if (explosionRadius > 0)
  36. {
  37. explosionRadius--;
  38. }
  39. }
  40. else
  41. {
  42. explosionRadius++;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement