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 <malloc.h> #include <stdlib.h> void Qsort(int left,int right,int a[100000]) {int i,j; i=left; j=right; int pivot = a[left]; while(i<j) { while(i<j && pivot <= a[j]) j--; if(i<j) a[i++] = a[j]; while(i<j && pivot > a[i]) i++; if(i<j) a[j--]=a[i]; } a[i]=pivot; if(i-left>1) Qsort(left,i-1,a); if(right-j>1) Qsort(j+1,right,a); } int main() {int i,n,m,j,k,flag=1; char a[100],b[8]; char con[27]="22233344455566677778889999"; int *c; c=(int*)malloc(100000*sizeof(int)); scanf("%d",&n); for(i=0;i<n;i++) {scanf("%s",a);k=0; for(j=0;a[j];j++) {if(a[j]>='A'&&a[j]<='Z') {b[k]=con[a[j]-'A'];k++;continue;} if(a[j]>='0'&&a[j]<='9') {b[k]=a[j];k++;} } c[i]=atoi(b); } Qsort(0,n-1,c); for(i=0;i<n;) {m=1; for(j=i+1;j<n&&c[i]==c[j];j++) m++; if(m>1) {flag=0; printf("%03d-%04d %d\n",c[i]/10000,c[i]%10000,m); } i=j; } if(flag) printf("No duplicates.\n"); free(c); return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator