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 |
我的程序能有好心人帮我看下吗?谢谢了~老是Wrong#include<stdio.h> #include<stdlib.h> #include<string.h> const char con[]="22233344455566677778889999"; typedef struct { char a[8]; int re; }tel; void Input(tel*T,int pos){ int i=0; for(i=0;i<7;i++){ scanf("%c",&T[ pos].a[i]); if(T[pos].a[i]=='-'){ i--; } else if(T[pos].a[i]>='A'&&T[pos].a[i]<='Z') T[pos].a[i]=con[T[pos].a[i]-'A']; } T[pos].re=0; } void Switch(tel&a,tel&b){ tel temp; temp=a; a=b; b=temp; } int Split(tel a[],int low,int high){ int i=low; tel x=a[low]; int j=0; for(j=low+1;j<=high;j++){ if(strcmp(a[j].a,x.a)<=0){ i++; if(i!=j)Switch(a[i],a[j]); } } Switch(a[low],a[i]); return i; } void QuickSort( tel a[],int low,int high){ int w=0; if(low<high){ w=Split(a,low,high); QuickSort(a,low,w-1); QuickSort(a,w+1,high); } } int main(){ int size; int i=0; int j=0; char n; int count=0; int pos=-1; tel T[100000]; scanf("%d",&size); getchar(); for(i=0;i<size;i++){ Input(T,i); while(scanf("%c",&n),n=='-'); } QuickSort(T,0,size-1); for(i=0;i<size;i++){ if(pos!=-1&&!strcmp(T[i].a,T[pos].a))T[pos].re++; else pos=i; } for(i=0;i<size;i++) if(T[i].re>0){ count++; for(j=0;j<7;j++){ if(j==3)printf("-"); printf("%c",T[i].a[j]); } printf(" %d\n",T[i].re+1); } if(!count)printf("No duplicates."); system("PAUSE"); return 1; } 我的方法比较笨,可是能帮我看下到底哪里错了吗??????谢谢了。。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator