View Code of Problem 36

#include<stdio.h>
#include<string.h>
int main(){
	int t,i,j,d,len,k;
	char str[1000];
	
	scanf("%d",&t);
	while(t--)
	{
		int nu[1000]={0};
		scanf("%s",&str);
		len=strlen(str);
		for(d=i=0;i<26;i++)
		{
			for(j=0;j<len;j++)
			  if(str[j]=='A'+d)
				 nu[d]++;
			d++;
		}
		for(j=d-1;j>=0;j--)
		{
			if(nu[j]!=0)
				break;
		}
				k=j;
		for(i=0;i<k;i++)
			if(nu[i]!=0)
				 printf("%d%c",nu[i],'A'+i);
			printf("%d%c\n",nu[k],'A'+k);
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 36