杭电 hdu 1020

Encoding:

#include<iostream>
#include<cstring>
using namespace std;
#define N 10001
char str[N];
int main(){
    int n;
    cin>>n;
    cin.ignore();
    while(n--){
        cin>>str;
        int len=strlen(str);
        int i;
        int count=1;
        for(i=0;i<len;++i){
            if(str[i]==str[i+1]){
                ++count;
            }
            else{
                if(count==1){
                    cout<<str[i];
                    count=1;
                }
                else{
                    cout<<count<<str[i];
                    count=1;
                }
            }
        }
        cout<<endl;
    }
    return 0;
}


你可能感兴趣的:(ACM,HDU,杭电,1020)