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 |
我知道为什么了!In Reply To:为什么我的程序总是错!谁有测试数据? Posted by:pillar at 2006-11-11 12:44:54 > #include <stdio.h> > #include <string.h> > #include <stdlib.h> > char ch[200000][100]; > const char let[]="22233344455566677778889999"; > int cmp(const void*a,const void*b){ > return strcmp((char*)a,(char*)b); > } > int main(){ > int n,i,j,k; > int len; > scanf("%d",&n); > for (i=0;i<n;++i) > { > scanf("%s",ch[i]); > len = strlen(ch[i]); > k = 0; > for (j=0;j<len;++j) > { > if (ch[i][j]>='0'&&ch[i][j]<='9') > ch[i][k++] = ch[i][j]; > else if (ch[i][j]>='A'&&ch[i][j]<='Z') > ch[i][k++] = let[ch[i][j]-'A']; > } > ch[i][k] = 0; > } > qsort(ch,n,sizeof(ch[0]),cmp); > k = len = 0; > for (i=0;i<n;++i) > { > if (strcmp(ch[i],ch[k])) > { > if (i-k>1) > { > len = 1; > for (j=0;j<3;++j) printf("%c",ch[i][j]); > printf("-"); > for (;j<7;++j) printf("%c",ch[i][j]); > printf(" %d\n",i-k); > } > k = i; > } > } > if (i-k>1) > { > len = 1; > for (j=0;j<3;++j) printf("%c",ch[i][j]); > printf("-"); > for (;j<7;++j) printf("%c",ch[i][j]); > printf(" %d\n",i-k); > } > if (len==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