#include<iostream> #include<string> #include<cstring> #include<algorithm> using namespace std; int main() { int t; string s; cin>>t; while(t--) { cin>>s; int ls=s.length(); int ll=1; for(int i=1;i<ls;i++) { if(s[i]!=s[i-1]) { cout<<ll<<s[i-1]; ll=1; } else ll++; } cout<<ll<<s[ls-1]; cout<<endl; } system("pause"); return 0; }
原文:http://www.cnblogs.com/baoluqi/p/3734379.html