View Code of Problem 36

#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main(void)
{
	int T;
	char str[1000];
	int sum[1000];
	scanf("%d", &T);
	while (T--)
	{
		memset(sum, 0, sizeof(sum));
		scanf("%s", str);
		for (int i = 0; i < 26; i++)
		{
			for (int j = 0; j < strlen(str); j++)
			{
				if (str[j] == i + 'A')
					sum[i]++;
			}
		}
		for (int i = 0; i < 26; i++)
		{
			if (sum[i])
				printf("%d%c", sum[i], i + 'A');
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 36