Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace RemoveOddOccurrences
- {
- public class RemoveOddOccurrences
- {
- public static void Main()
- {
- var input = Console.ReadLine().Split(new[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToList();
- input.Sort();
- input.Add(0);
- int currCounter = 1;
- int currNumber = 0;
- for (int i = 1; i < input.Count; i++)
- {
- currNumber = input[i - 1];
- if (input[i] == input[i - 1])
- {
- currCounter++;
- }
- else
- {
- if (currCounter %2 == 1)
- {
- for (int k = i-currCounter; k <i ; k++)
- {
- input[k] = 0;
- }
- }
- currCounter = 1;
- }
- }
- input.RemoveAll(x => x == 0);
- Console.WriteLine(string.Join(" ", input));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement