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 080401 at 2009-09-23 15:02:04 on Problem 1002
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int compare(const void *p1,const void *p2)
{
	return (strcmp( (char*)p1,(char*)p2 ));
}

char map[] = "22233344455566677778889999";
char str[80],tel[100001][9];

void stand( int n )
{
	int j,k;
	j = k = -1;
	while(k<8)
	{
		j++;
		if(str[j] == '-')
			continue;
		k++;
		if(k == 3)
		{
			tel[n][k] = '-';
			k++;
		}
		if( str[j]>='A'&&str[j]<='Z')
		{
			tel[n][k] = map[str[j]-'A'];
			continue;
		};
		tel[n][k] = str[j];
	}
		tel[n][k] = '\0';
	return;
}
int main()
{
	int n,i,j;
	bool pd;
	cin>>n;
	for( i = 0 ; i < n ; i++ )
	{
		scanf("%s",str);
		stand(i);
	}
	qsort(tel,n,9,compare);
	pd = true;
	i = 0;
	while(i<n)
	{
		j=i;
		i++;
		while(i<n && strcmp(tel[i],tel[j]) == 0)
			i++;
		if(i-j>1)
		{
			cout<<tel[j]<<' '<<i-j<<endl;
			pd = false;
		}
	}
	if(pd)
		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