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 huangwenyun at 2005-11-17 10:21:24 on Problem 1002
#include <iostream>
#include <string>
#include <list>
using namespace std;

list <string> M;

string s;

string make()
{
	string t="       ";int j=0;
	for (int i=0;i<s.size();i++)
	{
		if (s[i]!='-')
		{
			if (s[i]>=65&&s[i]<=67) t[j]='2';
			else
			if (s[i]>=68&&s[i]<=70) t[j]='3';
			else 
			if (s[i]>=71&&s[i]<=73) t[j]='4';
			else 
			if (s[i]>=74&&s[i]<=76) t[j]='5';
			else
			if (s[i]>=77&&s[i]<=79) t[j]='6';
			else
			if (s[i]>=80&&s[i]<=83) t[j]='7';
			else
			if (s[i]>=84&&s[i]<=86) t[j]='8';
			else
			if (s[i]>=87&&s[i]<=89) t[j]='9';
			else
			t[j]=s[i];
			j++;
		}
	}
	return t;
}

int main()
{
	int N;
	cin>>N;
	int flag=0;
	for (int i=0;i<N;i++)
	{
		cin>>s;
		M.push_back(make());
	}
	M.sort();s=M.front();
	M.pop_front();int num=1;
	while (!M.empty())
	{
		if (M.front()==s) num++;
		else 
		{
			if (num>1) 
			{cout<<s[0]<<s[1]<<s[2]<<"-"<<s[3]<<s[4]<<s[5]<<s[6]<<" "<<num<<endl;
			flag=1;}
			num=1;
		}
		s=M.front();
		M.pop_front();
	}
	if (flag==0) 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