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 |
Re:错在哪里?In Reply To:错在哪里? Posted by:cpp00548322 at 2006-03-12 15:20:10 输入0的时候好像就不对,有不止一个-的情况是不是也要考虑? 这题我一直wa,迷茫 > #include<string.h> > #include<stdio.h> > #include<stdlib.h> > > char result[100000][15]; > > int compare(const void * a,const void * b); > > int main() > { > char Letters[25]="ABCDEFGHIJKLMNOPRSTUWXY"; > char integers[25]="222333444555666777888999"; > int N;scanf("%d\n", &N); > if(N==0) return 1; > char teleNum[15]; > int i=0,value=1; > for(i=0 ; i < N ; i++) > { > scanf("%s",teleNum); > int len=strlen(teleNum),sign=0,k=0; > char chr; > for(k=0;k<=len;k++) > { > chr=teleNum[k]; > if(chr=='Q'||chr=='Z') break; > if(chr=='-') continue; > > else if(chr<='Z'&&chr>='A') > {int j=0; > for(j=0;j<24;j++) > if(chr==Letters[j]) break; > chr=integers[j]; > } > sprintf(result[i],"%s%c",result[i],chr); > sign++; > if(sign==3) > sprintf(result[i],"%s%c",result[i],'-'); > > } > } > //排序 > printf("%\n"); > qsort((void *)result, N, sizeof(result[0]),compare); > // printf("%\n"); > for(int q=0;q<N;q++)printf("%s\n",result[q]); > int repeat=1,j=0; > for(i=0;i<N;) > { > repeat=1; > if( strcmp(result[i],"ZQ")==0) continue; > for(j=i+1;j<N && strcmp(result[i],result[j])==0;j++) > repeat++; > > // if(i==N-2 && > if(repeat!=1) > { > printf("%s %d\n",result[i],repeat); > value=0; > } > i=j; > } > if(value)printf("No duplicates.\n"); > return 1; > } > > int compare(const void * a,const void * b) > { > return strcmp((char *)a,(char *)b); > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator