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.h> int main() { int a[100010],b[100010]={0}; char x[1000]; int t,num,cn=0,an; cin>>t; for(int i=0;i<t;i++) { num=0; an=0; cin>>x; int count=0; for(int j=0;;j++) { if(x[j]>='0'&&x[j]<='9') { num=num*10+int(x[j]-'0'); count++; } if(x[j]=='A'||x[j]=='B'||x[j]=='C') {num=num*10+2; count++; } if(x[j]=='D'||x[j]=='E'||x[j]=='F') {num=num*10+3; count++; } if(x[j]=='G'||x[j]=='H'||x[j]=='I') {num=num*10+4; count++; } if(x[j]=='J'||x[j]=='K'||x[j]=='L') {num=num*10+5; count++; } if(x[j]=='M'||x[j]=='N'||x[j]=='O') {num=num*10+6; count++; } if(x[j]=='P'||x[j]=='R'||x[j]=='S') {num=num*10+7; count++; } if(x[j]=='T'||x[j]=='U'||x[j]=='V') {num=num*10+8; count++; } if(x[j]=='W'||x[j]=='X'||x[j]=='Y') {num=num*10+9; count++; } //cout<<x[j]<<' '<<num<<endl; if(count==7) break; } //cout<<num<<endl; for(int k=0;k<cn;k++) { if(num==a[k]) { b[k]++; an=1; break; } } if(an==0) { a[cn]=num; //cout<<a[cn]<<endl; b[cn]++; //cout<<b[cn]<<endl; //cout<<cn<<endl; cn++; } } for(int pass=1;pass<cn;pass++) { int temp1,temp2; for(int i=0;i<cn-pass;i++) { if(a[i]>a[i+1]) { temp1=a[i]; temp2=b[i]; a[i]=a[i+1]; b[i]=b[i+1]; a[i+1]=temp1; b[i+1]=temp2; } } } //cout<<b[0]<<' '<<b[1]<<' '<<b[2]<<endl; int number=0; for(int q=0;q<cn;q++) { if(b[q]>1) { //cout<<a[q]<<' '; cout<<a[q]/10000<<'-'<<a[q]%10000<<' '<<b[q]<<endl; number++; } } 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