HDU 1020 Encoding

#include"stdio.h"
#include"string.h"
char str[10000];
void print(){
    scanf("%s",str);
    int i = 0,len = strlen(str),k;    
    char c ;
    while(i < len){
        c = str[i];
        k = i;
        while(str[++i] == c){            
        }
        if(i - k > 1)
            printf("%d%c",i - k,c);
        else
            printf("%c",c);
    }
    printf("\n");        
}
int main(){
    int nCases;
    scanf("%d",&nCases);
    while(nCases--){
        print();
    }
    return 0;    
}
posted @ 2011-04-10 06:36  L..  阅读(142)  评论(0编辑  收藏  举报