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:现在本题有人在做吗??In Reply To:现在本题有人在做吗?? Posted by:caonimama at 2007-04-12 14:27:40 #include<iomanip.h> #include<string.h> #include<stdio.h> char b[300],c[300]; int a[200005]; void quicksort(int b[],int s,int t) { int i=s,j=t+1,x; x=b[s]; do{ do i++;while(b[i]<x); do j--;while(b[j]>x); if(i<j) { int temp; temp=b[i]; b[i]=b[j]; b[j]=temp; } }while(i<j); b[s]=b[j]; b[j]=x; if(s<j-1)quicksort(b,s,j-1); if(j+1<t)quicksort(b,j+1,t); } int main() { int n,i,j,k=0,kk=0,number,nn; cin>>n; for(i=0;i<n;i++) { scanf("%s",&b);k=0; int len=strlen(b); for(j=0;j<len;j++)//将乱码转化成字符串 { 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'; } } number=0;nn=1; for(j=0;j<7;j++)//将字符串转化为整数 { for(k=0;k<(6-j);k++) { nn*=10; } number+=(c[j]-'0')*nn; nn=1; } a[kk++]=number;//将整数存入数组,kk计算数的个数 } k=0;nn=1;int count=1;number=0; quicksort(a,0,kk);//将数组中的数进行快速排序 for(i=1;i<=kk;i++)//将数据进行输出 { if(a[i+1]==a[i]) { count++; } else if(count>=2) { for(j=0;j<7;j++) { nn=1; for(k=0;k<(6-j);k++) { nn*=10; } if(j==3) { cout<<'-'<<a[i]/nn; } else { cout<<a[i]/nn; } a[i]-=(a[i]/nn)*nn; } cout<<" "<<count<<endl; /* if(count%2==0) { number=1; }*/ count=1;number=1; } } if(number==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