Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ex2()
- {
- int arr[N1] = {1,1,2,2,1,2,3,1,2,4,2,2};
- int i,j,max=0,flag=0,count=0,big=0;
- for (i=0;i<N1;i++)
- {
- count = 0;
- if (arr[i] != flag)
- {
- flag = arr[i];
- for (j=0;j<N1;j++)
- if (arr[j] == flag)
- {
- count++;
- }
- if (count > max)
- {
- max = count;
- big = flag;
- }
- }
- }
- cout<<"The Element "<<big<<" was found "<<max<<" times"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment