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 "cstdio" #include "cstring" class List { private: char buffer[1000]; int index; public: List() { index=0; } void put(char ch) { buffer[index++]=ch; } void clear() { index=0; } void print() { if(index==0) return; buffer[index]=0; putchar('1'); for(int i=0;buffer[i];i++) { if(buffer[i]=='1') putchar('1'); putchar(buffer[i]); } putchar('1'); } }; typedef struct { char character; int count; void print() { printf("%d%c",count,character); } }Code; Code codes[2000]; int clen; void put(char ch) { if(clen>0&&ch==codes[clen-1].character&&codes[clen-1].count<9) { codes[clen-1].count++; } else { codes[clen].character=ch; codes[clen].count=1; clen++; } } int main() { char buffer[2000]; int i,len; List list; while(gets(buffer)!=NULL) { if(buffer[0]==0) { puts(""); continue; } len=strlen(buffer); clen=0; for(i=0;i<len;i++) put(buffer[i]); for(i=0;i<clen;i++) { if(codes[i].count>1) { list.print(); list.clear(); codes[i].print(); } else list.put(codes[i].character); } list.print(); list.clear(); puts(""); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator