This is a program to find the number out of the given list of numbers which repeats the maximum no. of times.
We have predefined the numbers using array.
Code:
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int arr1[]={3,3,3,1,5,6,7};
int arr2[7];
int i,j,k=0,l=0;
for(i=0;i<8;i++)
{
arr2[i-1]=k;
k=0;
for(j=0;j<8;j++)
{
if(arr1[i]==arr1[j])
{
k++;
}
}
}
for(i=0;i<7;i++)
{
cout<<arr1[i]<<" has repeated "<<arr2[i]<<" times."<<endl;
}
cout<<endl<<"The maximum repeats are shown below:"<<endl;
for(i=0;i<8;i++)
{
if(l>1)
{
cout<<arr1[i-1]<<" has repeated "<<arr2[i-1]<<" times."<<endl;
l=0;
}
for(j=0;j<8;j++)
{
if(arr2[i]>arr2[j])
{
l++;
}
}
}
}