Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[10]={};
- void prelucrare_nr(int nr)
- {
- if (nr==0){ a[0]++; return;}
- while(nr!=0)
- {
- a[nr%10]++;
- nr=nr/10;
- }
- }
- int main()
- {
- int n,x,poz[10]={0,1,2,3,4,5,6,7,8,9};
- cin>>n;
- for(int i=1;i<=n;i++)
- {
- cin>>x;
- prelucrare_nr(x);
- }
- int ok=1;
- do
- {
- ok=1;
- for(int i=1;i<=9;i++)
- {
- if(a[i-1]>a[i])
- {
- swap(a[i-1],a[i]);
- swap(poz[i-1],poz[i]);
- ok=0;
- }
- }
- }
- while(ok==0);
- for(int i=0;i<=9;i++)
- {
- if(a[i]>0)
- cout<<poz[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement