Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- char m[1002];
- int v[1002];
- void HtL(int lenth)
- {
- int y,z,temp;
- char tm;
- for(y=0; y<lenth; y++)
- {
- for(z=y+1;z<lenth;z++)
- {
- if( v[y] == v[z])
- {
- if( m[z] > m[y] )
- {
- temp = v[y];
- tm = m[y];
- v[y] = v[z];
- m[y] = m[z];
- v[z] = temp;
- m[z] = tm;
- }
- }
- else if( v[y] > v[z])
- {
- temp = v[y];
- tm = m[y];
- v[y] = v[z];
- m[y] = m[z];
- v[z] = temp;
- m[z] = tm;
- }
- }
- }
- m[y] = '\0';
- }
- int main()
- {
- char s[1002];
- int i,j,k,x,ln;
- while(1)
- {
- for(i=0;;i++)
- {
- s[i] = getchar();
- if( s[i] == '\n')
- {
- break;
- }
- }
- s[i] = '\0';
- ln = i;
- for(i=0,x=0,k=0; i<ln; i++)
- {
- if( s[i] == '+')
- {
- continue;
- }
- m[x] = s[i];
- for(j=i+1; j<ln; j++)
- {
- if( s[j] == '+')
- {
- continue;
- }
- if(s[i] == s[j])
- {
- v[k]++;
- s[j] = '+' ;
- }
- }
- v[k]++;
- x++;
- k++;
- }
- m[x] = '\0';
- HtL(k);
- for(j=0; j<x; j++)
- {
- printf("%d %d\n",m[j],v[j]);
- v[j] = 0;
- }
- printf("\n");
- m[0]='\0';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement