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<string.h> #include<stdlib.h> char tel_number[100001][50]; char temp_number[100001][9]; int result[100001]; void QuickSort(char data[][9], int left, int right) { int i,j; char iTemp[9]; char middle[9]; i=left; j=right; strcpy(middle,data[(left+right)/2]); do { while((strcmp(data[i],middle)<0) && (i<right)) i++; while((strcmp(data[j],middle)>0) && (j>left)) j--; if(i<=j) { strcpy(iTemp,data[i]); strcpy(data[i],data[j]); strcpy(data[j],iTemp); i++; j--; } }while(i<=j); if(left<j) QuickSort(data,left,j); if(right>i) QuickSort(data,i,right); } int main() { int test; int i,j,k; char temp; int flag; scanf("%d",&test); for(i=0;i<test;i++) { getchar(); scanf("%s",tel_number[i]); k=0; for(j=0;j<strlen(tel_number[i]);j++) { temp=tel_number[i][j]; if(k==3) temp_number[i][k++]='_'; if(temp>='A' && temp<='C') temp_number[i][k++]='2'; else if(temp>='D' && temp<='F') temp_number[i][k++]='3'; else if(temp>='G' && temp<='I') temp_number[i][k++]='4'; else if(temp>='J' && temp<='L') temp_number[i][k++]='5'; else if(temp>='M' && temp<='O') temp_number[i][k++]='6'; else if(temp=='P' || temp=='R' || temp=='S') temp_number[i][k++]='7'; else if(temp>='T' && temp<='V') temp_number[i][k++]='8'; else if(temp>='W' && temp<='Y') temp_number[i][k++]='9'; else if(temp>='0' && temp<='9') temp_number[i][k++]=temp; } } QuickSort(temp_number,0,test-1); memset(result,0,sizeof(result)); j=0; for(i=0;i<test;i++) { for(j=i; j<test;j++) { if(strcmp(temp_number[j],temp_number[i])!=0) break; result[i]++; } i=j-1; } flag=0; for(i=0;i<test;i++) { if(result[i]>1) { flag=1; printf("%s %d\n",temp_number[i],result[i]); } } if(flag==0) printf("No duplicates.\n"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator