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 |
牛们救救这个RE者吧!!#include<iostream> #include<cstring> using namespace std; #define ma 100010 #define m 100 char pzj[]="22233344455566677778889999"; char num[ma][m]; //记录转换后的电话号码 int i,j; bool ak[m]; char s[m],ss[m]; char tem[m],ter[m]; int ps(int tail,int head)//字典排序 { int w,t; w=tail,t=head; strcpy(tem,num[(w+t)>>1]); while(1) { while(strcmp(num[w],tem)<0)w++; while(strcmp(num[t],tem)>0)t--; if(w<=t) { strcpy(ter,num[w]); strcpy(num[w],num[t]); strcpy(num[t],ter); w++,t--; } else break; } if(w<head) ps(w,head); if(t>tail) ps(tail,t); return 0; } int main() { int n,len; memset(num,0,sizeof(num)); memset(s,0,sizeof(s)); memset(ss,0,sizeof(ss)); scanf("%d",&n); for(i=1;i<=n;i++) { int k=0; scanf("%s",s); len=strlen(s); for(j=0;j<len;j++) { if(s[j]>='A'&&s[j]<='Z') num[i][k++]=pzj[s[j]-'A']; if(s[j]>='0'&&s[j]<='9') num[i][k++]=s[j]; } } ps(1,n); strcpy(ss,num[1]); bool check=1; int count=1; memset(ak,1,sizeof(ak)); for(i=1;i<=n;i++) { if(!strcmp(num[i],num[i+1])&&ak[i]) { ak[i]=0; count++; check=0; } else { strcpy(ss,num[i]); if(count>1) { for (j=0;j<7;j++) { if (j!=3) printf("%c",ss[j]); else printf("-%c",ss[j]); } printf(" %d\n",count); count=1; } } } if(check) printf("No duplicates.\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator