Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- struct numere
- {
- int x,nr;
- }q[10];
- int comparare (numere a, numere b)
- {
- if((a.nr>b.nr)||(a.nr==b.nr&&a.x>b.x)) return 1;
- else return 0;
- }
- int i,n,x,u,v[10],a,mn,nr,p=0,j,b[11],c[102];
- int main()
- {
- cin>>n;
- for(i=1;i<=n;i++)
- {
- cin>>x;
- a=x;
- for(j=0;j<=9;j++)
- {
- b[j]=0;
- }
- while(a!=0)
- {
- u=a%10;
- v[u]++;
- b[u]=1;
- a=a/10;
- }
- nr=0;
- for(j=0;j<=9;j++)
- {
- if(b[j]==1) nr++;
- }
- if(nr==2) {p++;c[p]=x;}
- }
- mn=999999999;
- for(i=0;i<=9;i++)
- {
- if(v[i]<mn) {mn=v[i];x=i;}
- }
- cout<<x<<"\n";
- for(i=0;i<=9;i++)
- {
- q[i].x=i;
- q[i].nr=v[i];
- }
- sort(q,q+10,comparare);
- for(i=0;i<=9;i++) cout<<q[i].x<<" ";
- cout<<"\n";
- sort(c,c+p+1);
- if(p==0) cout<<-1;
- else for(i=1;i<=p;i++)
- {
- cout<<c[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement