Решить задачу на C#
Дан целочисленный массив размера N. Найти количество различных элементов в данном массиве.
Ответы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharpPrj3
{
class Program
{
static void Main(string[] args)
{
int size = 10;
int[] array = new int[size];
List<int> a = new List<int>();
for (int i = 0; i < size; ++i)
{
array[i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i < size; ++i)
{
if (!a.Contains(array[i]))
{
a.Add(array[i]);
}
else
{
continue;
}
}
Console.WriteLine($"Unique elements: {a.Count}");
Console.ReadKey();
}
}
}