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