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 |
加上“V”还是不OK……#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); 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(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