Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int c0, c1, c2, c3, c4, c5, c6, c7, c8, c9;
- int main()
- {
- int n, c, x, i;
- cout<<"n="; cin>>n;
- for(i=1; i<=n; i++)
- {
- cin>>x;
- while(x!=0)
- {
- c=x%10;
- if(c==0)
- c0++;
- if(c==1)
- c1++;
- if(c==2)
- c2++;
- if(c==3)
- c3++;
- if(c==4)
- c4++;
- if(c==5)
- c5++;
- if(c==6)
- c6++;
- if(c==7)
- c7++;
- if(c==8)
- c8++;
- if(c==9)
- c9++;
- x=x/10;
- }
- }
- for(i=1; i<=c0; i++)
- cout<<0<<" ";
- for(i=1; i<=c1; i++)
- cout<<1<<" ";
- for(i=1; i<=c2; i++)
- cout<<2<<" ";
- for(i=1; i<=c3; i++)
- cout<<3<<" ";
- for(i=1; i<=c4; i++)
- cout<<4<<" ";
- for(i=1; i<=c5; i++)
- cout<<5<<" ";
- for(i=1; i<=c6; i++)
- cout<<6<<" ";
- for(i=1; i<=c7; i++)
- cout<<7<<" ";
- for(i=1; i<=c8; i++)
- cout<<8<<" ";
- for(i=1; i<=c9; i++)
- cout<<9<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment