HDU 1020

#include<stdio.h>
#include<string.h>
char str[10001];
int main()
{
    int T,i,cnt,len;
    char *p,*q;
    scanf("%d",&T);
    while(T--)
    {
        cnt = 1;
        scanf("%s",str);
        len = strlen(str);
        p = str;
        for(q = p; q < str+len;q++ )
        {
            while(*q==*(q+1))
            {
                cnt++;
                q++;
            }
            if(cnt!=1)
            {
                printf("%d%c",cnt,*q);
                cnt = 1;
            }
            else
                printf("%c",*q);
        }
        puts("");
    }
    return 0;
}


posted on 2014-04-30 18:34  wangzhili  阅读(66)  评论(0编辑  收藏  举报