Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求大神帮忙看一下为什么老是WA

Posted by 1917 at 2013-05-20 15:19:35 on Problem 1002
#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;
vector<string> v;
string change(string s) {
	string temp;
	for(int i=0;i<(int)s.length();i++) {
		if('0'<=s[i]&&s[i]<='9')
			temp+=s[i];

		else{
			switch(s[i]) {
			case 'A':
			case 'B':
			case 'C':temp=temp+'2';break;
			case 'D':
			case 'E':
			case 'F':temp=temp+'3';break;
			case 'G':
			case 'H':
			case 'I':temp=temp+'4';break;
			case 'J':
			case 'K':
			case 'L':temp+='5';break;
			case 'M':
			case 'N':
			case 'O':temp+='6';break;
			case 'P':
			case 'R':
			case 'S':temp+='7';break;
			case 'T':
			case 'U':
			case 'V':temp+='8';break;
			case 'W':
			case 'X':
			case 'Y':temp+='9';break;
			}
		}
	}
	return temp;
}
int main() {
	int N;
	string temp;
	cin>>N;
	for(int i=0;i<N;i++) {
		cin>>temp;
		temp=change(temp);
		v.push_back(temp);
	}
	sort(v.begin(),v.end());
	int num=1,flag=1;
	for(int i=1;i<N;i++) {
		if(v[i]==v[i-1]) {
			num++;
			continue;
		}else{
			if(num>1) {
				flag=0;
				for(int j=0;j<(int)v[i-1].length();j++) {
					if(j==3)
						cout<<"-";
					cout<<v[i-1][j];
				}
				cout<<" "<<num<<endl;
			}
			num=1;
		}
	}
	if(flag==1)
		cout<<"No duplicates."<<endl;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator