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" #define Q 10000 void main() {int i,n,j,k,c,flag; struct student{ char p[20]; int a;}; struct student q[Q],ew[Q],*b[Q],*t; c=1; scanf("%d",&n); for(i=0;i<n;i++) {scanf("%s",ew[i].p); k=0; for(j=0;ew[i].p[j]!='\0';j++) { if(ew[i].p[j]!='-') { switch(ew[i].p[j]) {case 'A': case 'B': case 'C':ew[i].p[j]='2';break; case 'D': case 'E': case 'F':ew[i].p[j]='3';break; case 'G': case 'H': case 'I':ew[i].p[j]='4';break; case 'J': case 'K': case 'L':ew[i].p[j]='5';break; case 'M': case 'N': case 'O':ew[i].p[j]='6';break; case 'P': case 'R': case 'S':ew[i].p[j]='7';break; case 'T': case 'U': case 'V':ew[i].p[j]='8';break; case 'W': case 'X': case 'Y':ew[i].p[j]='9';break; } q[i].p[k]=ew[i].p[j]; k++; } if(k==3) { q[i].p[k]='-'; k++; } q[i].p[k]='\0'; } } for(i=0;i<n;i++) b[i]=&q[i]; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(b[i]->p,b[j]->p)>0) {t=b[j]; b[j]=b[i]; b[i]=t;} k=0; for(i=0;i<n-1;) {flag=0; c=1; for(j=i+1;j<n;j++) if(strcmp(b[i]->p,b[j]->p)==0) { flag=1; c++; b[i]->a=c; } if(flag==1) { printf("%s",b[i]->p); printf(" ");printf("%d\n",b[i]->a); k++; } if(c!=1) i=i+c; else {b[i]->a=c; i++;} } if(k==0) printf("No duplicates.\n "); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator