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<iostream> #include<cstdlib> #include<cstring> using namespace std; char map[]="22233344455566677778889999"; char str[80],telnum[100000][9]; int main() { void change(int); int compare(const void*elem1,const void*elem2); int n,i,j; bool a; cin>>n; for(i=0;i<n;i++) { cin>>str; change(i); } qsort(telnum,n,9,compare); a=true; for(i=0;i<n;i++) { j=i; i++; while(i<n&&strcmp(telnum[i],telnum[j])==0) i++; if(i-j>1) { cout<<telnum[j]<<" "<<i-j<<endl; a=false; } } if(a) cout<<"No duplicates."<<endl; return 0; } void change(int n) { int j,k; j=-1; k=-1; while(k<8) { j++; if(str[j]=='-') continue; k++; if(k==3){ telnum[n][k]='-'; k++; } if(str[k]>='A'&&str[k]<='Z') { telnum[n][k]=map[str[j]-'A']; } else telnum[n][k]=str[j]; } telnum[n][k]='\0'; } int compare(const void*elem1,const void*elem2) { return(strcmp((char*)elem1,(char*)elem2)); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator