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<iostream.h> #include<stdio.h> #include<stdlib.h> #define MAX 100000 int cmp(const void *t1,const void *t2) { int *a,*b; a=(int *)t1; b=(int *)t2; if (*a>*b) return 1; if (*a<*b) return -1; return 0; } void main() { char maps[]="2223334445556667777888999\0"; int i,j,n=0; long int k,k1; scanf("%d",&k); k1=k; int * count; count=new int[k]; for(i=0;i<k;i++) count[i]=1; char telnum1[8]; char * telnum2; int telnum[MAX]; while(k!=0) { telnum2=new char[100]; scanf("%s",telnum2); i=0; j=0; while(j<7) { if('0'<=telnum2[i]&&telnum2[i]<='9') { telnum1[j]=telnum2[i]; j++; } else if('A'<=telnum2[i]&&telnum2[i]<'Z') { telnum1[j]=maps[telnum2[i]-'A']; j++; } i++; } telnum[n]=atoi(telnum1); n++; k--; delete[]telnum2; } qsort(telnum,k1,sizeof(int),cmp); j=0;n=0; for(i=0;i<k1;i++) { if(telnum[i]==telnum[i+1]) j=i; while(telnum[i]==telnum[i+1]) { count[j]++; i++; } i++; } n=0; for(i=0;i<k1;i++) { if(count[i]>1) { printf("%d-%d %d\n",telnum[i]/10000,telnum[i]%10000,count[i]); n=1; } } if(n==0) printf("No duplicates."); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator