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