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 |
牛人帮忙看一下为什么给的数据通过了却得到WA,我都晕了!!!#include<stdio.h> #include<string.h> #include<stdlib.h> int comp(const void *a,const void *b) { return strcmp((char *)a,(char *)b); } int main() { long first,len,i=0,k=0,count=0; int j=0,flag=0; char a[100001][9],b[16],c[16]; /*char a[1000][9],b[16],c[16];*/ while(scanf("%ld",&first)!=EOF) { flag=0; len=first; j=0;i=0;k=0;count=0; while(first--!=0) { scanf("%s",b); for(j=0;b[j]!='\0';j++)/*transfer letter to number.*/ { switch(b[j]) { case 'A': case 'B': case 'C': b[j]='2';break; case 'D': case 'E': case 'F': b[j]='3';break; case 'G': case 'H': case 'I': b[j]='4';break; case 'J': case 'K': case 'L': b[j]='5';break; case 'M': case 'N': case 'O': b[j]='6';break; case 'P': case 'R': case 'S': b[j]='7';break; case 'T': case 'U': case 'V': b[j]='8';break; case 'W': case 'X': case 'Y': b[j]='9';break; } } /*transfer letter to number.*/ /*puts(b);*/ for(j=0,i=0;b[j]!='\0';j++)/*delete all '-' in numbers*/ { if(b[j]!='-') { c[i]=b[j]; i++; } } c[i]='\0';/*delete all '-' in numbers*/ /*puts(c);*/ for(i=6;;i--)/*insert '-' in the fourth place.*/ { if(i==2) break; c[i+1]=c[i]; } c[3]='-'; c[8]='\0';/*insert '-' in the fourth place.*/ /*puts(c);*/ strcpy(a[k++],c); /*puts(a[k-1]);*//*RIGHT just before this*/ } qsort(a,len,sizeof(a[0]),comp);/*sort*/ for(i=0;i<len;i++)/*print consequence*/ { if(strcmp(a[i],a[i+1])==0) { count++; continue; } count++; if(count>1) { printf("%s %Ld\n",a[i],count); flag=1; } count=0; }/*print consequence*/ 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