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

求高人指教,在VC中测试正确呀,为啥老是WA呢?

Posted by 161110125 at 2013-04-18 16:40:14 on Problem 1002
#include <cstdio>
#include <map>
#include <iterator>
using namespace std;

const int dic[26]=
{
	2,2,2,//ABC
	3,3,3,//DEF
	4,4,4,//GHI
	5,5,5,//JKL
	6,6,6,//MNO
	7,//P
	-1,//Q
	7,7,//RS
	8,8,8,//TUV
	9,9,9,//WXY
	-1//Z
};

bool getAndTransToSdd(char des[])
{
	char src[20];
	if (scanf("%s",src))
	{
		memset(des,'\0',strlen(des));
		int len = strlen(src);
		int desCur=0;
		for (int i = 0;i<len;i++)
		{
			if (src[i]>='0' && src[i]<='9')
			{
				des[desCur]=src[i];
				desCur++;
			} 
			else if (src[i]>='A' && src[i]<='Z')
			{
				des[desCur]='0'+dic[src[i]-'A'];
				desCur++;
			}
			else if (src[i]>='a' && src[i]<='z')
			{
				des[desCur]='0'+dic[src[i]-'a'];
				desCur++;
			}
		}
		return true;
	}
	else
	{
		return false;
	}
}

int main()
{
	map<int,int>mem;
	int n,i;
	char des[10]={'\0'};
	bool someRepeat=false;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		getAndTransToSdd(des);
		mem[atoi(des)]++;
	}
	for (map<int,int>::iterator it=mem.begin();it!=mem.end();it++)
	{
		if (it->second>1)
		{
			someRepeat=true;
			printf("%03d-%04d %d\n",it->first/10000,it->first%10000,it->second);
		}
	}
	if (!someRepeat)
	{
		printf("No duplicates.\n");
	}
	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