#include<iostream> #include<algorithm> #include<math.h> using namespace std; int main() { int t; cin>>t; while(t--) { string h; cin>>h; sort(h.begin(),h.end()); char c; int num=0; for(int i=0;i<h.length();i++) { if(i==0) { c=h[i]; num++; } else { if(h[i]==c) { num++; } else { cout<<num<<c; c=h[i]; num=1; } } } cout<<num<<c<<endl; } return 0; } |
Double click to view unformatted code.