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