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 |
WA的看看这组数据,虽然跟题意不符,但是是测试数据。。。。。。This is a multi line chapter [3] to check description recognition [3] and this is a long description yes, it is 过了这组就行了,实在BT 顺便贴下代码 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> char reference[1024][256]; int r[1024]={0}; int b[1024]={0}; bool flag=false; char article[256]={0}; bool blank() { int i=0; while(article[i]!='\0') { if(article[i]!=' ') return false; i++; } return true; } int change(int &n) { int i=0,sum=0; char dig[8]={0}; for(i=n+1;article[i]!=']';i++) { dig[i-n-1]=article[i]; } sum=atoi(dig); n=i; return sum; } int main() { int i=0,N=0,count=1,temp=0,count1=0; char *p=NULL; memset(reference,0,sizeof(reference)); while((p=gets(article))&&p!=NULL) { N=strlen(article); if(blank()) { flag=1; continue; } if(article[0]!='['||(article[0]=='['&&!flag)) { if(flag) { if(count1!=0) { printf("\n"); } flag=false; } for(i=0;i<N;i++) { count1=1; if(article[i]!='[') { printf("%c",article[i]); } else { temp=change(i); if(r[temp]==0) { r[temp]=count; b[count-1]=temp; printf("[%d]",count); count++; } else { printf("[%d]",r[temp]); } } } printf("\n"); } else { i=0; temp=change(i); strcpy(reference[temp],article+i+1); strcat(reference[temp],"\n"); while((p!=NULL)&&(p=gets(article))&&!blank()) { strcat(reference[temp],article); strcat(reference[temp],"\n"); } if(p==NULL) { break; } } } printf("\n"); for(i=0;i<count-1;i++) { printf("[%d]",i+1); puts(reference[b[i]]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator