View Code of Problem 36

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

Double click to view unformatted code.


Back to problem 36