Kamrul13981

Untitled

Jun 12th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int i,j,n,count;
  6.  
  7.     cout<<"Enter no. of elements:";
  8.     cin>>n;
  9.  
  10.     int set[n];
  11.     cout<<"\nEnter the elements:";
  12.     for(i=0; i<n; i++)
  13.     {
  14.        cin>>set[i];
  15.     }
  16.  
  17.  
  18.     int flag[n]={0};
  19.     cout<<"\nRepeated Numbers with their frequency:";
  20.     for(i=0; i<n; i++)
  21.     {
  22.       count=0;
  23.       if(flag[i]!=1)
  24.       {
  25.          for(j=0; j<n; j++)
  26.          {
  27.             if(set[i]==set[j])
  28.             {
  29.               count++;
  30.               flag[j]=1;
  31.             }
  32.          }
  33.          if(count>1)
  34.          {
  35.            cout<<"\n"<<set[i]<<" -> "<<count;
  36.          }
  37.       }
  38.     }
  39. return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment