/* © MATTO MATTI 2019 http://mattomatti.com/pl/a0205 napisane przy użyciu Visual Studio Community 2015 2019-01-31 v 1.0 */ using System; using System.Collections.Generic; namespace plcode1cs { class Program { static List unikalneElementy(List lista) { List wynik = new List(); for (int i = 0; i < lista.Count; i++) { bool dopisz = true; for (int j = 0; j < i; j++) { if (lista[i] == lista[j]) { dopisz = false; break; } } if (dopisz) { wynik.Add(lista[i]); } } return wynik; } static void Main(string[] args) { Console.WriteLine("Podaj elementy tablicy:"); string[] data = Console.ReadLine().Split(' '); List lista = new List(); foreach(string s in data) { lista.Add(Convert.ToInt32(s)); } Console.WriteLine("Unikalne elementy to:"); List wynik = unikalneElementy(lista); foreach(int a in wynik) { Console.Write("{0} ", a); } Console.ReadKey(); } } }