http://acm.hdu.edu.cn/showproblem.php?pid=1020
分析: 遍历
代码:
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<iostream>
#define LL long long
using namespace std;
int main()
{
int n;
string s;
scanf("%d",&n);
while(n--){
cin>>s;
for(int i=0;i<s.length();){
int j=i+1;
int cnt=1;
while(j<s.length()&&(s[i]==s[j])){
cnt++;
j++;
}
if(cnt==1) cout<<s[i];
else cout<<cnt<<s[i];
i=j;
}
cout<<endl;
}
return 0;
}