Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int cmmnr(int n)
- {
- int a[10],i,cn=n,nr,j;
- for(i=0; i<=9; i++)
- {
- a[i]=0;
- while(n!=0)
- {
- if(n%10==i)
- a[i]++;
- n=n/10;
- }
- n=cn;
- }
- if(a[0]==0)
- { nr=0;
- for(i=1; i<=9; i++)
- if(a[i]!=0)
- {
- for(j=1; j<=a[i]; j++)
- nr=nr*10+i;
- }
- }
- else
- {
- nr=0;
- for(i=1; i<=9; i++)
- if(a[i]!=0)
- {
- nr=nr*10+i;
- a[i]--;
- break;
- }
- for(i=0; i<=9; i++)
- if(a[i]!=0)
- {
- for(j=1; j<=a[i]; j++)
- nr=nr*10+i;
- }
- }
- return nr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement