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 <iostream> using namespace std; void qsort(int a[100000],int left,int right); void main() { int a[100000]; char b[50]; int num; cin>>num; if (num<2) { cin>>b; cout<<"No duplicates."; } else { for (int i=0;i<num;i++) { cin>>b; int p1=0; int result=0; for (int j=0;j<strlen(b);j++) { char tmp=b[j]; switch(tmp) { case('A'): case('B'): case('C'): { b[j]='2'; break; } case('D'): case('E'): case('F'): { b[j]='3'; break; } case('G'): case('H'): case('I'): { b[j]='4'; break; } case('J'): case('K'): case('L'): { b[j]='5'; break; } case('M'): case('N'): case('O'): { b[j]='6'; break; } case('P'): case('R'): case('S'): { b[j]='7'; break; } case('T'): case('U'): case('V'): { b[j]='8'; break; } case('W'): case('X'): case('Y'): { b[j]='9'; break; } case(' '): { b[j]='.'; break; } } if (b[j]>='0' && b[j]<='9') { b[p1++]=b[j]; result=10*result+b[j]-('1'-1); } } a[i]=result; } qsort(a,0,num-1); int flag=0; int pp=0; while(pp<num) { int sum=1; int i=1; while(a[pp]==a[pp+i]) { i++; sum++; } if (sum>1) { int x1=a[pp]/10000; int y1=a[pp] % 10000; if (x1>99) cout<<x1<<"-"; else if (x1>9) cout<<"0"<<x1<<"-"; else cout<<"00"<<x1<<"-"; //cout<<"-"; if (y1>999) cout<<y1<<" "<<sum<<endl; else if (y1>99) cout<<"0"<<y1<<" "<<sum<<endl; else if (y1>9) cout<<"00"<<y1<<" "<<sum<<endl; else if (y1>=0) cout<<"000"<<y1<<" "<<sum<<endl; flag=1; // cout<<" "<<sum<<endl; } pp=pp+i; } if (flag==0) cout<<"No duplicates."; } } void qsort(int a[100000],int left,int right) { if (left<right) { int lft=left; for (int b=lft+1;b<=right;b++) if ((a[b]<a[left]) && b!=++lft) { int t; t=a[lft]; a[lft]=a[b]; a[b]=t; /* swap(a[b],a[lft]);*/ } int t1; t1=a[lft]; a[lft]=a[left]; a[left]=t1; /* swap(a[left],a[lft]);*/ qsort(a,left,lft-1); qsort(a,lft+1,right); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator