-
I have changed the code in order not to use '*' or mallocs or frees...
As in my previous code, the modes are returned in the first positions of array, while the number of modes, are returned in the "int" return of the function.
int mode(int array[], int SIZE_OF_ARRAY)
{
//using namespace std;
int count = 0;
int max = 0;
int count2 = 0;
for(int i = 0; i < SIZE_OF_ARRAY; i++)
{
count = 0;
for(int j = i; j < SIZE_OF_ARRAY; j++)
{
if(array[i] == array[j])
{
count++;
}
}
if(count > max)
{
max = count;
count2 = 0;
array[count2] = array[i];
}
else if(count == max)
{
count2++;
array[count2] = array[i];
}
}
count2++;
return count2;
}
-
thank you guys for all your help and advice...Caronte, thanks for the code and you time...
peace