題目連接:php
http://acm.hdu.edu.cn/showproblem.php?pid=1020less
題目類型:this
字符串的簡單處理spa
題意歸納:code
對字符串進行縮略,將一個字符串中連續的n個相同的字符縮略成字符n的形式。blog
題目:ip
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 45946 Accepted Submission(s): 20310
字符串
# include <stdio.h> # include <string.h> int main () { int i,j,t,l; char b[10010]; scanf("%d",&t); getchar(); while(t--) { gets(b); l=strlen(b); b[l]='a';b[l+1]='\0'; l++; int num=1; for(i=1;i<l;i++) { if(b[i]!=b[i-1]) { if(num!=1) printf("%d",num); printf("%c",b[i-1]); num=1; } else num++; } printf("\n"); } }