Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
高手帮我看看呀,实在不知道错在哪里,测试数据都准确#include <stdio.h> #include <string.h> int main(){ char buf[10000]; int i,j,length,count=1,albe=0; while(gets(buf)!=NULL){ length=strlen(buf); for(i=0,j=1;i<length;i++,j++){ if(buf[i]==buf[j]){ count++; if(count>9){ printf("9%c",buf[i]); count=count-9; } if(albe==1){ printf("1"); albe=0; } } else{ if(count==1){ if(albe==0) { printf("1"); albe=1; } if(buf[i]=='1') printf("%s","11"); else printf("%c",buf[i]); } else if(count>1){ printf("%d%c",count,buf[i]); count=1; } } } if(albe==1){ albe=0; printf("1"); } printf("%\n"); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator