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"stdlib.h" #include"string.h" struct code { int a[8]; code *next; code *front; }; void main() { int n,c[7],i,j,k,z,key=0; char b[100]; code *p,*q,*r,*f,*e; scanf("%d",&n); q=(code *)malloc(sizeof(code)); p=q; for(z=0;z<n;z++) { scanf("%s",b); for(i=0,j=0;i<strlen(b);i++) { if(b[i]=='0') { c[j]=0; j++; } if(b[i]=='1') { c[j]=1; j++; } if(b[i]=='A'||b[i]=='B'||b[i]=='C'||b[i]=='2') { c[j]=2; j++; } if(b[i]=='D'||b[i]=='E'||b[i]=='F'||b[i]=='3') { c[j]=3; j++; } if(b[i]=='G'||b[i]=='H'||b[i]=='I'||b[i]=='4') { c[j]=4; j++; } if(b[i]=='J'||b[i]=='K'||b[i]=='L'||b[i]=='5') { c[j]=5; j++; } if(b[i]=='M'||b[i]=='N'||b[i]=='O'||b[i]=='6') { c[j]=6; j++; } if(b[i]=='P'||b[i]=='R'||b[i]=='S'||b[i]=='7') { c[j]=7; j++; } if(b[i]=='T'||b[i]=='U'||b[i]=='V'||b[i]=='8') { c[j]=8; j++; } if(b[i]=='W'||b[i]=='X'||b[i]=='Y'||b[i]=='9') { c[j]=9; j++; } } if(p==q) { q=(code *)malloc(sizeof(code)); for(i=0;i<7;i++) { p->a[i]=c[i]; } (p->a[i++])=1; p->next=q; q->front=p; } else { for(i=0,key=0,r=p;key!=1;i++) { for(j=0;j<7;j++) { for(f=p,k=0;k<i;k++) { f=f->next; } if(c[j]!=(f)->a[j]) { r=r->next; if(r==q) { q=(code*)malloc(sizeof(code)); for(j=0;j<7;j++) { r->a[j]=c[j]; } (r->a[j++])=1; r->next=q; q->front=r; key=1; } break; } else { if(j==6) { for(k=0,r=p;k<i;k++) { r=r->next; } ((r)->a[7])++; key=1; } } } } } } for(i=0;p->a[7]<=1&&p!=q;i++) { p=p->next; } if(p!=q) { r=p; for(i=0;r!=q;i++) { if(r->a[7]<=1) { r->front->next=r->next; r->next->front=r->front; r=r->next; } else r=r->next; } for(i=0;p!=q;i++) { if(p->next==q) { for(k=0;k<8;k++) { printf("%d",p->a[k]); if(k==7) printf("\n"); if(k==3) printf("-"); if(k==6) printf(" "); } break; } for(j=0,e=q->front,r=p;r->front!=e;j++) { for(k=0;k<7;k++) { if(e->a[k]<r->a[k]) { r=r->next; break; } else if(e->a[k]>r->a[k]) { e=e->front; break; } else if(k==6&&e->a[k]==r->a[k]) { if(p!=e) { e->front->next=e->next; e->next->front=e->front; for(k=0;k<8;k++) { printf("%d",e->a[k]); if(k==7) printf("\n"); if(k==3) printf("-"); if(k==6) printf(" "); } e=q->front; break; } else { for(k=0;k<8;k++) { printf("%d",p->a[k]); if(k==7) printf("\n"); if(k==3) printf("-"); if(k==6) printf(" "); } p=p->next; r=p; break; } } } } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator