class Program
{
static void Main(string[] args)
{
int[] num = new int[] { 0, 1, 1, 23, 4, 4, 5, 65,
90, 7, 7, 10, 200, 10000 };
System.Console.WriteLine($"There is
{CheckDuplicate(num)} duplicates number");
}
// Write a program in C# Sharp to count a total
//number of duplicate elements in an array.
public static int CheckDuplicate(int[] numbers)
{
int total = 0;
for (int i = 0; i < numbers.Length; i++)
{
for (int j = 0; j < numbers.Length; j++)
{
if (numbers[i] == numbers[j])
{
total++;
break;
}
}
}
return total;
}
}
0 Comments
If you have any question please ask?