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> int sort(const void *,const void *); char tel[100000][16],Tel[100000][16]; long *time,*c; long t,i,j,k,l,z=0; void main() { scanf("%d",&t); time=new long[t]; c=new long[t]; for(i=0;i<t;i++) { scanf("%s",tel[i]); c[i]=0; for(j=0;j<(int)strlen(tel[i]);j++) { if(tel[i][j]<81&&tel[i][j]>64) tel[i][j]=char(int((tel[i][j]-'A'+1)/3.1)+50); if(tel[i][j]>81) tel[i][j]=char(int((tel[i][j]-'A')/3.1)+50); } l=0; for(k=0;l<8;k++) { if(l==3) { Tel[i][l]='-'; l++; k--; continue; } if(tel[i][k]!='-') { Tel[i][l]=tel[i][k]; l++; } } } qsort(Tel,t,sizeof(Tel[0]),sort); for(i=0;i<t;i++) { for(k=0;k<t;k++) { if(!strcmp(Tel[i],Tel[k])) c[i]++; } for(j=0;j<i;j++) { if(!strcmp(Tel[j],Tel[i])) goto loop; } if(c[i]>1) { z++; printf("%s %d\n",Tel[i],c[i]); } loop: i++; i--; } if(!z) printf("%s\n","No duplicates."); delete [] time; delete [] c; } int sort(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