How to find the Mode in Array C#?
Posted
by
sarah
on Stack Overflow
See other posts from Stack Overflow
or by sarah
Published on 2011-11-24T17:10:42Z
Indexed on
2011/11/24
17:51 UTC
Read the original article
Hit count: 165
c#
I want to find the Mode in an Array. I know that I have to do nested loops to check each value and see how often the element in the array appears. Then I have to count the number of times the second element appears. The code below doesn't work, can anyone help me please.
for (int i = 0; i < x.length; i ++)
{
x[i]++;
int high = 0;
for (int i = 0; i < x.length; i++)
{
if (x[i] > high)
high = x[i];
}
}
© Stack Overflow or respective owner