标签:
1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<cstring> 5 using namespace std; 6 char ch[15000],before; 7 int num,n; 8 int main(){ 9 scanf("%d",&n); 10 while(n!=0) 11 { 12 n--; 13 scanf("%s",ch); 14 int len=strlen(ch); 15 before=ch[0]; 16 num=1; 17 for (int i=1;i<len;++i) 18 { 19 if (ch[i]==before) 20 num++; 21 else 22 { 23 if (num!=1) 24 printf("%d%c",num,before); 25 else 26 printf("%c",before); 27 num=1; 28 before=ch[i]; 29 } 30 31 }if (num!=1) 32 printf("%d%c\n",num,before); 33 else 34 printf("%c\n",before); 35 36 } 37 return 0; 38 }
标签:
原文地址:http://www.cnblogs.com/fakerv587/p/5179200.html