#include<stdio.h> #include<string.h> int main() { int n; while (scanf("%d",&n)!=EOF) { char str[1000]; while (n--) { int a[26] = { 0 }; gets(str); int len = strlen(str); for (int i = 0; i < len; i++) { a[str[i] - 'A']++; } for (int i = 0; i < 26; i++) { if (a[i] != 0) printf("%d%c", a[i], i + 'A'); else if (i = 25) printf("\n"); } } } return 0; } |
Double click to view unformatted code.