Advertisement
vencinachev

A5

Dec 2nd, 2020
2,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace GerryTutor
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static List<int> NonRepeat(int[] arr)
  13.         {
  14.             HashSet<int> set = new HashSet<int>();
  15.             foreach (var item in arr)
  16.             {
  17.                 set.Add(item);
  18.             }
  19.             return set.ToList();
  20.         }
  21.         static void Main(string[] args)
  22.         {
  23.             int[] arr = { 8, 10, 31, 19, 8, 8, 31, 10 };
  24.  
  25.             List<int> l = NonRepeat(arr);
  26.             foreach (var item in l)
  27.             {
  28.                 Console.WriteLine(item);
  29.             }        
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement