#include<stdio.h> #include<string.h> int main(void) { int T; scanf("%d", &T); char str[1000]; int sum[26]; int vis[26]; while (T--) { memset(sum, 0, sizeof(sum)); memset(vis, 0, sizeof(vis)); scanf("%s", str); int len = strlen(str); for (int i = 0; i < len; i++) { sum[str[i] - 'A']++; vis[str[i] - 'A'] = 1; } for (int i = 0; i < 26; i++) { if (vis[i]) printf("%d%c", sum[i], 'A' + i); } printf("\n"); } return 0; } |
Double click to view unformatted code.