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 |
请问qsort怎么使用 为什么我总是发送错误报告#include <stdio.h> #include <string.h> #include <stdlib.h> char a[100000][16]; int compare(const void*,const void *); void main() { int N; int i,j,k; scanf("%d",&N); for(i=0;i<N;i++){ scanf("%s",a[i]); for(j=0;a[i][j]!='\0';){ if(a[i][j]<='9'&&a[i][j]>='0'){ j++;continue; } if(a[i][j]=='A'||a[i][j]=='B'||a[i][j]=='C'){ a[i][j]='2'; j++; continue; } if(a[i][j]=='D'||a[i][j]=='E'||a[i][j]=='F'){ a[i][j]='3'; j++; continue; } if(a[i][j]=='G'||a[i][j]=='H'||a[i][j]=='I'){ a[i][j]='4'; j++; continue; } if(a[i][j]=='J'||a[i][j]=='K'||a[i][j]=='L'){ a[i][j]='5'; j++; continue; } if(a[i][j]=='M'||a[i][j]=='N'||a[i][j]=='O'){ a[i][j]='6'; j++; continue; } if(a[i][j]=='P'||a[i][j]=='R'||a[i][j]=='S'){ a[i][j]='7'; j++; continue; } if(a[i][j]=='T'||a[i][j]=='U'||a[i][j]=='V'){ a[i][j]='8'; j++; continue; } if(a[i][j]=='W'||a[i][j]=='X'||a[i][j]=='Y'){ a[i][j]='9'; j++; continue; } if(a[i][j]=='-'){ for(k=j;a[i][k]!='\0';k++){ a[i][k]=a[i][k+1]; } } } } qsort((void*)a,N,sizeof(a[0]),compare); int s=1; for(j=0;j<N;j++){ if(strcmp(a[j+1],a[j])==0) s++; else{ if(s>1){ for(i=0;i<3;i++){ printf("%c",a[j][i]); } printf("-"); for(i=3;i<7;i++){ printf("%c %d\n",a[j][i],s); } s=1; } } } } int compare(const void * aa,const void * ba) { return strcmp(* (char * * )aa,* (char * * )ba); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator