0
What will be the code for finding the element which occurs with maximum frequency and also to display its frequency in an arra.
2 Antworten
+ 1
for (int i = 0; i < (nElements - 1); i++) {
for (int j = (i + 1); j < nElements; j++) {
if (array[ j ] == array[ i ])
num++;
}
countingArray[ i ] = num;
}
I think this will do what you're asking for? then just use a bubble sorter to find which one occurs the most
+ 1
sorry, this is not correct for your question. You will need a nested for loop, most likely though. the code I gave you will recount elements. if you know exactly which values will occur more than once, it would be much easier. I also have some code for determining the amount of times a letter appears in a char array.