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