Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace testyy
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine().Split(">").ToList();
- int power = 0;
- int additionalpower = 0;
- for (int i = 0; i < input.Count; i++)
- {
- if (input[i].Any(c => char.IsDigit(c)))
- {
- power = int.Parse(input[i][0] + "");
- if (power>1 && input[i].Length<2)
- {
- int oldpower = power;
- power = 1;
- additionalpower += oldpower - power;
- }
- input[i] = input[i].Substring(power);
- if (i==input.Count-1 && additionalpower > 0)
- {
- input[i] = input[i].Substring(additionalpower);
- }
- }
- }
- Console.WriteLine(string.Join(">",input));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment