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 |
总是wrong answer,请高手们帮忙看一下哪里错了,不胜感激,万分感谢,谢谢,谢谢,谢谢!#include<iostream.h> #include<stdlib.h> #include<stdio.h> struct tel { int num; char telnum[8]; tel*next; }; void main() { char*telnum1; int i=0,j=0,n=0,k,k1=0; tel*head,*ps,*pend,*head1,*head2; head=new tel; head->num=1; ps=head; pend=head; head1=head; pend->next=NULL; cin>>k; while(k!=0) { ps=new tel; ps->num=1; telnum1=new char[20]; scanf("%s",telnum1); while(j<7) { if(telnum1[i]>='0'&&telnum1[i]<='9') { ps->telnum[j]=telnum1[i]; j++; } else if('L'<telnum1[i]&&telnum1[i]<'Z') { if('M'<=telnum1[i]&&'O'>=telnum1[i]) ps->telnum[j]='6'; else if('P'<=telnum1[i]&&'S'>=telnum1[i]) ps->telnum[j]='7'; else if('T'<=telnum1[i]&&'V'>=telnum1[i]) ps->telnum[j]='8'; else if('W'<=telnum1[i]&&'Y'>=telnum1[i]) ps->telnum[j]='9'; j++; } else if('A'<=telnum1[i]&&telnum1[i]<'M') { if(telnum1[i]>='A'&&telnum1[i]<='C') ps->telnum[j]='2'; else if('D'<=telnum1[i]&&'F'>=telnum1[i]) ps->telnum[j]='3'; else if('G'<=telnum1[i]&&'I'>=telnum1[i]) ps->telnum[j]='4'; else if('J'<=telnum1[i]&&'L'>=telnum1[i]) ps->telnum[j]='5'; j++; } i++; } while(1) { if(atoi(pend->telnum)<atoi(ps->telnum)) { pend->next=ps; pend=ps; pend->next=NULL; break; } else if(atoi(pend->telnum)==atoi(ps->telnum)) { pend->num++; delete ps; break; } while(1) { if(atoi(head1->telnum)==atoi(ps->telnum)) { head1->num++; delete ps; n=1; break; } else if(atoi(head1->telnum)>atoi(ps->telnum)) { ps->next=head1; head=ps; n=1; break; } while(atoi(head1->telnum)<atoi(ps->telnum)) { head2=head1; head1=head1->next; } if(atoi(head1->telnum)==atoi(ps->telnum)) { head1->num++; delete ps; n=1; break; } else if(atoi(head1->telnum)>atoi(ps->telnum)) { ps->next=head1; head2->next=ps; n=1; break; } } if(n==1) { head1=head; break; } } delete[]telnum1; n=0; i=0; j=0; k--; } delete ps; while(head->next!=NULL) { if(head->num!=1) { for(i=0;i<3;i++) cout<<head->telnum[i]; cout<<'-'; for(i=3;i<7;i++) cout<<head->telnum[i]; cout<<" "<<head->num<<endl; k1++; } head=head->next; } if(head->num==1&&k1==0) cout<<"No duplicates."<<endl; else if(head->num!=1) { for(i=0;i<3;i++) cout<<head->telnum[i]; cout<<'-'; for(i=3;i<7;i++) cout<<head->telnum[i]; cout<<" "<<head->num<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator