Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- List<decimal> input = Console.ReadLine()
- .Split()
- .Select(decimal.Parse)
- .ToList();
- for (int i = 0; i < input.Count-1; i++)
- {
- if (input[i] == input[i+1])
- {
- input[i] += input[i + 1];
- input.RemoveAt(i+1);
- i = -1;
- }
- }
- Console.WriteLine(string.Join(" ", input));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment