0
Find what is the most occurred number on the given numbers
example: 1 2 3 2 5 The most occurred number is 2
8 Answers
+ 3
@GODOF7
I have posted a solution on a copy of this thread. Have you seen that?
+ 3
#include<iostream>
#include<algorithm>
#include<iterator>
using namespace std;
int main()
{
    int arr[5];  for(int &i:arr) cin>>i;
    int maxe=0, maxctr=0;
    for(int i : arr)
    {
         int c = count(begin(arr),end(arr),i);
         if(c > maxctr) 
        {  maxe = i; maxctr = c;  }
    }
    cout<<maxe<<" is the most frequent "
    <<"element. \nIt occurred "<<maxctr
    <<" times."<<endl;
}
0
thank you very much
0
it doesnt work yho, why?
0
if I change it to 5 is it gonna make a difference?
0
chnage the a[20] to a[5]
0
the result is always zero



