Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int i,j,max,noOfChar=0;
- char arr[10000];
- scanf("%s",arr);
- max=arr[0]-96;
- for(i=1;arr[i]!='\0';++i){
- if(arr[i]-96>max){
- max=arr[i]-96;
- }
- }
- max++;
- int brr[max];
- for(i=0;i<max;++i){
- brr[i]=0;
- }
- for(i=0;arr[i]!='\0';++i){
- brr[arr[i]-96]++;
- }
- for(i=0;i<max;++i){
- if(brr[i]!=0){
- noOfChar++;
- }
- }
- int crr[max];
- for(i=0;i<max;++i){
- crr[i]=brr[i];
- }
- for(i=0;i<max;++i){
- for(j=0;j<max-i-1;++j){
- if(crr[j]<crr[j+1]){
- crr[j]=crr[j]+crr[j+1];
- crr[j+1]=crr[j]-crr[j+1];
- crr[j]=crr[j]-crr[j+1];
- }
- }
- }
- for(i=0;i<max-1;++i){
- for(j=1;j<max;++j){
- if(brr[j]==crr[i]){
- int loop=crr[i];
- while(loop--){
- printf("%c",(j+96));
- }
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement