#include <iostream> #include<string.h> using namespace std; int main() { int t; scanf("%d",&t); char ch[1000]; while(t--) { int word[26]={0}; scanf("%s",ch); int l=strlen(ch); for(int i=0;i<l;i++) { int j=ch[i]-'A'; word[j]++; } for(int i=0;i<26;i++) { if(word[i]!=0) { printf("%d",word[i]); char j='A'+i; printf("%c",j); } } printf("\n"); } return 0; } |
Double click to view unformatted code.