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 |
帮我看看,我不知是什么错了,是runtime error ,谢谢了!#include "stdio.h" #include "string.h" int main() { char c,**str=NULL; char **tist=NULL,*cpy=NULL; int n,i,j,f,h,t; int *a=NULL; int k=0; scanf("%d",&n); str=(char**)malloc(n*sizeof(char*)); tist=(char**)malloc(n*sizeof(char*)); a=(int *)malloc(n*sizeof(char*)); for(i=0;i<n;i++) { a[i]=1; tist[i]=(char*)malloc(13*sizeof(char)); str[i]=(char*)malloc(16*sizeof(char)); scanf("%s",str[i]); for(j=0,h=0;str[i][j]!='\0';j++) { c=str[i][j]; if(c=='0') tist[k][h++]='0'; else if(c=='1') tist[k][h++]='1'; else if(c=='A'||c=='B'||c=='C'||c=='2') tist[k][h++]='2'; else if(c=='D'||c=='E'||c=='F'||c=='3') tist[k][h++]='3'; else if(c=='G'||c=='H'||c=='I'||c=='4') tist[k][h++]='4'; else if(c=='J'||c=='K'||c=='L'||c=='5') tist[k][h++]='5'; else if(c=='M'||c=='N'||c=='O'||c=='6') tist[k][h++]='6'; else if(c=='P'||c=='R'||c=='S'||c=='7') tist[k][h++]='7'; else if(c=='T'||c=='U'||c=='V'||c=='8') tist[k][h++]='8'; else if(c=='W'||c=='X'||c=='Y'||c=='9') tist[k][h++]='9'; if(h==3) tist[k][h++]='-'; } tist[k][h]='\0'; for(f=0; f<k&&strcmp(tist[f],tist[k])!=0; f++) ; if(f==k) k++; else a[f]++; } for(i=0;i<k;i++) { for(j=i;j<k;j++) if(strcmp(tist[i],tist[j])>0) { cpy=tist[i]; tist[i]=tist[j]; tist[j]=cpy ; t= a[j]; a[j]=a[i]; a[i]=t; } } for(i=0;i<n;i++) { if(a[i]>1) printf("%s %d\n",tist[i],a[i]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator