I have 30 random number and store in array and it be will pass to this function. I need to count occurs most frequently number in size of 30.
1 2 3 4 5 6 7 8 9 10 11 12 13
//int count[size2];
int max=0;
for (int index = 0; index < size2; index ++)
{
if (max < mode[index])
{
max = mode[index];
cout <<"This is the max " << max << " Position is " << mode[index]<< endl;
}
}
Output is
This is the max 19 Position is 19
This is the max 24 Position is 24
This is the max 27 Position is 27
This is the max 29 Position is 29
This is the max 30 Position is 30
This is the max 1513237040 Position is 1513237040
This is the max 1800426096 Position is 1800426096
int max=0;
for (int index = 0; index >size2; index ++)
{
// count[mode[index] - 1]++;
if (mode[index] > max)
{
max = mode[index];
cout <<"This is the max " << max << " Position is " << mode [index]<< endl;
}
}
i change it and it outter bound:
the output is
This is the max 20 Position is 20
This is the max 26 Position is 26
This is the max 52 Position is 52
This is the max 64 Position is 64
This is the max 78 Position is 78
This is the max 85 Position is 85
This is the max 88 Position is 88
This is the max 91 Position is 91
This is the max 94 Position is 94
This is the max 99 Position is 99