Please help me with the code to find the most repeated number in an array. The code below is not working perfectly.
int p =o;
int[,] numbers = {{1, 2, 0, 6 },
{5, 6, 7, 0 },
{9, 3, 6, 2 },
{6, 4, 8, 1}};
int []A = new int [16];
foreach (int n in numbers)
{
A[P] = n;
P++;
}
P = -1;
for (int x = 0; x < A.Length; x++)
{
for (int y = 0; y < A.Length; y++)
{
if (A[x] == A[y])
{
if (x != y)
{
if (A[x] > P) P = A[x];
}
}
}
}
if (P == -1) Console.WriteLine("There's No repeated number ");
else Console.WriteLine("The most repeated number is {0}", P);