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> void main() { int n; int i,j,k,m=0; int min; int f=0; int sdex; int *flag; int *index; int *fdex; char **str; scanf("%d",&n); flag = new int[n]; index = new int[n]; fdex =new int[n]; str =new char*[n]; for(i=0;i<n;i++) { flag[i]=0; str[i]=new char[16]; } for(i=0;i<n;i++) { index[i]=0; fdex[i]=0; } for(i=0;i<n;i++) { k=0; j=0; scanf("%s",str[i]); while(str[i][j] != '\0') { if(str[i][j] >= 'A' && str[i][j] <= 'P') { str[i][k]=(str[i][j]-'A')/3 +'2'; k++; } else if(str[i][j] >= 'R' && str[i][j] <='Y') { str[i][k]=(str[i][j]-'A'-1)/3 +'2'; k++; } else if(str[i][j] >='0' && str[i][j] <='9') { str[i][k]=str[i][j]; k++; } j++; } str[i][k]='\0'; for(k=0;k<i;k++) { if(strcmp(str[i],str[k])==0) { flag[k]++; if(fdex[k] == 0) { index[m++]=k+1; fdex[k]=1; } break; } } } for(i=0;i<n;i++) { if(flag[i] != 0) f=1; } if(f==0) { printf("No duplicates.\n"); return; } for(i=0;i<m;i++) { min=index[i]-1; for(k=i+1;k<m;k++) { if(strcmp(str[min],str[index[k]-1]) > 0) { min=index[k]-1; sdex=k; } } for(j=0;j<3;j++) printf("%c",str[min][j]); putchar('-'); for(j=3;j<8;j++) printf("%c",str[min][j]); printf(" %d\n",flag[min]+1); index[sdex]=index[i]; index[i]=0; } delete []index; delete []flag; delete []fdex; for(i=0;i<n;i++) { delete []str[i]; } delete []str; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator