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啊,我的程序跟那些个AC的好像是一样的啊!请高人指点一下!

Posted by riy at 2006-11-22 15:01:41 on Problem 1002
#include <iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<iomanip>
using namespace std;

int main(){
         string ma="22233344455566677778889999";
	int round;
	cin>>round;
	vector<int> h(round);
	string tempPhone;
	for(int i=0;i<round;i++){
		cin>>tempPhone;
		string temp="";
		for(int j=0;j<tempPhone.size();j++)
			if(tempPhone[j]!='-'){
				if(tempPhone[j]>='A' && tempPhone[j]<='Z')
					temp+=ma[tempPhone[j]-'A'];
				else temp+=tempPhone[j];
			}
		h[i]=atoi(temp.c_str());
	}
	sort(h.begin(),h.end());
	bool flag=false;
	for(int i=0;i<round;i++){
		int j=i+1;
		while(h[i]==h[j] && j<round)j++;
		if(j-i>1){
			flag=true;
			cout<<setfill('0')<<setw(3)<<h[i]/10000<<'-'
				<<setfill('0')<<setw(4)<<h[i]%10000<<' '<<j-i<<endl;
			i=j;
		}
	}
	if(!flag)
		cout<<"No duplicates."<<endl;
}

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