View Code of Problem 36

#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;

int main () {
    int T;
	char str[1005];
	int state[26];
	cin >> T; 
    getchar();
	while (T--) {
        memset(state, 0, sizeof state);
        gets(str);
        int len = strlen(str);
        for (int i = 0; i < len; i++) {
            state[str[i] - 'A']++;
        }
        for (int i = 0; i < 26; i++) {
            if (state[i]) printf("%d%c", state[i], i+'A');
        }
        putchar('\n');
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 36