- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrequencyCount2.cpp
More file actions
Latest commit
40 lines (39 loc) · 589 Bytes
/
Copy pathFrequencyCount2.cpp
File metadata and controls
40 lines (39 loc) · 589 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
usingnamespacestd;
intmain()
{
int arr[100],n,i,j;
cout<<"Enter the size of array : \n";
cin>>n;
cout<<"Enter element in array :\n";
for(i=0;i<n;i++)
{
cin>>arr[i];
}
int arr1[n];
int dupArr=-1;
for(i=0;i<n;i++)
{
int count=1;
for(j=i+1;j<n;j++)
{
if(arr[i]==arr[j])
{
count++;
arr1[j]=dupArr;
}
}
if(arr1[i]!=dupArr)
{
arr1[i]=count;
}
}
for(i=0;i<n;i++)
{
if(arr1[i]!=dupArr)
{
cout<<"Duplicates value in array is "<<arr[i]<<" : "<<arr1[i]<<"\n";
}
}
return0;
}