HDU 1020

#include <iostream>
#include <cstring>
using namespace std;
const int N = 10000;

int main(){
    int T,len,i,j,cnt;
    char str[N];
    cin>>T;
    while(T--){
            cnt=1;
        cin>>str;
        len=strlen(str);
        for(i=0;i<len;i++){
            while(str[i]==str[i+1]){
                cnt++;
                i++;
            }
            if(cnt==1)
            cout<<str[i];
    else{
        cout<<cnt<<str[i];
        cnt=1;
        }
        }
    cout<<endl;
    }
    return 0;
}

posted @ 2016-05-30 20:46  弃用博客  阅读(175)  评论(0编辑  收藏  举报