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.h> # include <string.h> # include <stdlib.h> char letter[8][4]={"ABC","DEF","GHI","JKL","MNO","PRS","TUV","WXY"}; char number[9]={"23456789"}; int compare(const void* a, const void* b); char * change(char *a); int N,n; void main() { char ** array; bool turn=false; cin>>N; array=new char*[N]; for(int i=0;i<N;i++){ //将号码全部转换为数字串 cin>>array[i]; cout<<array[i]; change(array[i]); } qsort((void*)array,N,sizeof(array[0]),compare); char b[9]; strcpy(b,array[0]); for(int j=1;j<N;j++){ if(strcmp(array[j],b)==0) {n++;turn=true; continue;} if(n>1){ for(int k=0;b[k]!='\0';k++){ if(k==3) cout<<"-"<<b[k]; else cout<<b[k]; } cout<<" "<<n<<endl; n=1;strcpy(b,array[j]); } } if(!turn) cout<<"No duplicates."<<endl; delete[]array; } int compare(const void* a,const void* b){ return strcmp(*(char **)a,*(char **)b); } char * change(char *a){ int y; char *p=a,*q=a; for(;*p!='\0';p++){ if(*p>='A' && *p<='Z'){ for(y=0;y<8;y++){ if(strchr(letter[y],*p)!=NULL){ *q=number[y];q++;} } } if(*p>='0' && *p<='9'){ *q=*p; q++;} } *q='\0'; return a; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator