#include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; char s[1100000]; int main() { int z; cin>>z; getchar(); while(z--) { int i,j,k,l; gets(s); l = strlen(s); int t = 1; for(i = 1;i<=l;i++) { if(s[i]!=s[i-1]) { if(t!=1) printf("%d",t); putchar(s[i-1]); t = 1; } else t++; } puts(""); } return 0; }
原文:http://www.cnblogs.com/wos1239/p/4581667.html