View Code of Problem 36

#include<stdio.h>
#include<string.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t)
	{
		char a[1000];
		gets(a);
		int i,j;
		int len=strlen(a);
		char temp;
		for(i=0;i<len;i++)
		{
			for(j=i+1;j<len;j++)
			{
				if(a[i]>a[j])
				{
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
			}
		}
	    i=0;
	    while(a[i])
		{
			int n=1;
			while(a[i+1]&&a[i+1]==a[i])
			{
				i++;
				n++;
			}
			printf("%d%c",n,a[i]);
			i++;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 36