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> #include<string> using namespace std; int main() { int n,i,j,count[100],m,l,x,k; string word[100],newword[100],last[100],temp; cin>>n; for (i=0;i<n;i++) { count[i]=1; } for (i=0;i<n;i++) { cin>>word[i]; l=sizeof(word[i]); for (j=0;j<l;j++) { if (word[i][j]!='-') { newword[i]+=word[i][j]; } } for (j=0;j<7;j++) { switch(newword[i][j]) { case'A':case'B':case'C': newword[i][j] = '2';break; case'D':case'E':case'F': newword[i][j] = '3';break; case'G':case'H':case'I': newword[i][j] = '4';break; case'J':case'K':case'L': newword[i][j] = '5';break; case'M':case'N':case'O': newword[i][j] = '6';break; case'P':case'R':case'S': newword[i][j] = '7';break; case'T':case'U':case'V': newword[i][j] = '8';break; case'W':case'X':case'Y': newword[i][j] = '9';break; } } } for (i=0;i<n;i++) { for (j=i+1;j<n;j++) { if (newword[i]>newword[j]) { temp=newword[i]; newword[i]=newword[j]; newword[j]=temp; } } } j=0; count[j]=1; last[j]=newword[0]; for (i=0;i<n;i++) { x=1; for (k=0;k<7;k++) { if (last[j][k]!=newword[i+1][k]) { x=0; } } if (x==1) { count[j]++; } else { j++; last[j]=newword[i+1]; } } m=j; x=0; for (i=0;i<m;i++) { if (count[i]>1) { x=1; for (j=0;j<3;j++) { cout<<last[i][j]; } cout<<"-"; for (j=3;j<8;j++) { cout<<last[i][j]; } cout<<" "<<count[i]; cout<<endl; } } if (x==0) { cout<<endl<<"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