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> using namespace std; void sort(int a[][2],int p ,int r) { int x,i,j,temp,q; if(p<r) { x=a[r][0]; i=p-1; for (j=p;j<=r-1;j++) if (a[j][0]<=x) { i++; temp=a[i][0]; a[i][0]=a[j][0]; a[j][0]=temp; temp=a[i][1]; a[i][1]=a[j][1]; a[j][1]=temp; } temp=a[i+1][0]; a[i+1][0]=a[r][0]; a[r][0]=temp; temp=a[i+1][1]; a[i+1][1]=a[r][1]; a[r][1]=temp; q=i+1; sort(a,p,q-1); sort(a,q+1,r); } return ; } int main() { int array[89]={0},i,j,flage,total=0; int n,num,s; int a[100000][2],k=1000000,l; char b[100],c[100]; j=2; for(i=65;i<81;i++) { array[i]=j; s=i-1; if((s)%3==0){j+=1;} } array[83]=array[82]=7; array[86]=array[84]=array[85]=8; array[89]=array[87]=array[88]=9; cin>>n; for(i=0;i<n;i++) { a[i][0]=0;a[i][1]=0;} for(i=0;i<n;i++) { num=0; cin>>b; l=strlen(b); k=1000000; for(j=0;j<l;j++) { s=0; if(b[j]!='-') { if(b[j]<='9'&&b[j]>='0') { s=(int)(b[j])-48; } else s=array[(int)(b[j])]; } else continue; num+=s*k; k=k/10; } flage=1; for(j=1;j<=total;j++) { if(a[j][0]==num) { a[j][1]++; flage=0; break; } } if(flage==1) { total++; a[total][0]=num; a[total][1]+=1; } } s=0; sort(a,1,total); for(i=1;i<=total;i++) { if (a[i][1]>1) { itoa(a[i][0],c,10); l=strlen(c); for (j=l-1;j>=0;j--) c[j+7-l]=c[j]; for (j=0;j<=6-l;j++) c[j]='0'; for (j=0;j<=2;j++) cout<<c[j]; cout<<"-"; for (j=3;j<=6;j++) cout<<c[j]; cout<<" "<<a[i][1];cout<<endl;s=1; } } if(s==0){cout<<"0";} system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator