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<iomanip.h> #include<string.h> #include<stdio.h> char a[100005][1000],b[1000],c[1000]; int aa[100005]={0}; void quicksort(char b[][1000],int bb[],int s,int t) { int i=s,j=t+1; char x[1000]; strcpy(x,b[s]); int xx=bb[s]; do{ do i++;while(strcmp(b[i],x)<0); do j--;while(strcmp(b[j],x)>0); if(i<j) { char temp[1000]; strcpy(temp,b[i]); strcpy(b[i],b[j]); strcpy(b[j],temp); int te=bb[i]; bb[i]=bb[j]; bb[j]=te; } }while(i<j); strcpy(b[s],b[j]); strcpy(b[j],x); bb[s]=bb[j]; bb[j]=xx; if(s<j-1)quicksort(b,bb,s,j-1); if(j+1<t)quicksort(b,bb,j+1,t); } int main() { int n,i,j,k=0,kk=0; cin>>n; for(i=0;i<n;i++) { scanf("%s",&b);k=0; int len=strlen(b); for(j=0;j<len;j++) { if(k==3) { c[k++]='-'; } if(b[j]>='0'&&b[j]<='9') { c[k++]=b[j]; } else if(b[j]>='A'&&b[j]<='C') { c[k++]='2'; } else if(b[j]>='D'&&b[j]<='F') { c[k++]='3'; } else if(b[j]>='G'&&b[j]<='I') { c[k++]='4'; } else if(b[j]>='J'&&b[j]<='L') { c[k++]='5'; } else if(b[j]>='M'&&b[j]<='O') { c[k++]='6'; } else if(b[j]>='P'&&b[j]<='S') { c[k++]='7'; } else if(b[j]>='T'&&b[j]<='V') { c[k++]='8'; } else if(b[j]>='W'&&b[j]<='Y') { c[k++]='9'; } } for(j=0;j<kk;j++) { if(strcmp(a[j],c)==0) { aa[j]++; break; } } if(j>=kk) { aa[kk]++; strcpy(a[kk++],c); } } k=0; quicksort(a,aa,0,kk); for(i=1;i<=kk;i++) { if(aa[i]>=2) { cout<<a[i]<<" "<<aa[i]<<endl; k++; } } if(k==0) { cout<<"No duplicates."<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator