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; int num[26]; int tran(char a) { if(int(a)>=97 && int (a)<=int ('z')) return num[int(a)-97]; else if(int(a)>=int('A') && int (a)<=int ('Z')) return num[int(a)-int('A')]; else if(int (a)>=int('0') && int(a)<=int('9')) return int(a)-int('0'); else return -1; } int deng(int *a,int *b) { for(int i=0;i<7;i++) { if(a[i]<b[i]) return -1; else if(a[i]>b[i]) return 1; } return 0; } void main() { int i,n,j; char a; num[0]=num[1]=num[2]=2; num[3]=num[4]=num[5]=3; num[6]=num[7]=num[8]=4; num[9]=num[10]=num[11]=5; num[12]=num[13]=num[14]=6; num[15]=num[17]=num[18]=7; num[19]=num[20]=num[21]=8; num[22]=num[23]=num[24]=9; num[16]=num[25]=-1; cin>>n; int directory[100][8]; for(i=-1;i<n;i++) { int k=0; do{ a=cin.get(); j=tran(a); if(j>=0 && j<=9 &&k<7) { directory[i][k]=j; k++; } }while(a!='\n'); directory[i][7]=1; } for(i=0;i<n;i++) if(directory[i][7]!=0) for(j=i+1;j<n;j++) { if(directory[j][7]!=0) if(deng(directory[j],directory[i])==0) { directory[j][7]=0; directory[i][7]++; } } bool d=true; int t[100]; int k=0; for(i=0;i<n;i++) if(directory[i][7]>=2) { t[k++]=i; cout<<t[k-1]<<endl; } for(i=1;i<k;i++) { j=i; int s=t[i]; while(j>0&& deng(directory[t[i]],directory[t[j-1]])==1) { t[j]=t[j-1]; j--; } t[j]=s; } for(i=k-1;i>=0;i--) { for(j=0;j<3;j++) cout<<directory[t[i]][j]; cout<<'-'; for(j=3;j<7;j++) cout<<directory[t[i]][j]; cout<<" "<<directory[t[i]][7]<<endl; } if(k==0) cout<<"No duplicates."<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator