View Code of Problem 36

#include <stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		char s[1000];
		scanf("%s", s);
		int len = strlen(s);
		int a[26] = { 0 };
		for (int i = 0; i < len; i++)
		{
			if (s[i] >= 'A' && s[i] <= 'Z')
			{
				int j = s[i] - 'A';
				a[j]++;
			}
		}
		for (int i = 0; i < 26; i++)
		{
			if (a[i] == 0)
				continue;
			else
			{
				printf("%d", a[i]);
				printf("%c", 'A' + i);
			}
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 36