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

造了个轮子+map解决了

Posted by 16111204040 at 2017-04-15 16:00:57 on Problem 1002
#include<iostream>
#include<map>
using namespace std;
int vczh_over(char ch)
{
	switch(ch)
	{
	case '0':return 0;
	case '1':return 1;
	case '2':
	case 'A':
	case 'B':
	case 'C':return 2;
	case '3':
	case 'D':
	case 'E':
	case 'F':return 3;
	case '4':
	case 'G':
	case 'H':
	case 'I':return 4;
	case '5':
	case 'J':
	case 'K':
	case 'L':return 5;
	case '6':
	case 'M':
	case 'N':
	case 'O':return 6;
	case '7':
	case 'P':
	case 'R':
	case 'S':return 7;
	case '8':
	case 'T':
	case 'U':
	case 'V':return 8;
	case '9':
	case 'W':
	case 'X':
	case 'Y':return 9;
	default :return -1;
	}
}
int main()
{
	map <int,int> tel;
	map <int,int>::iterator iter;
	int _;fscanf(stdin,"%d",&_);
	for(int i=0;i<_;i++)
	{
		char ch;int num=0,step=0;
		while(1)
		{
			fscanf(stdin,"%c",&ch);
			if(ch=='-')continue;
			if(ch=='\n')continue;
			num=num*10+vczh_over(ch);
			step++;
			if(step==7) break;
		}
		if(tel[num]>=1)
			tel[num]++;
		else
			tel[num]=1;
	}
	int flag=1;
	for(iter=tel.begin();iter!=tel.end();iter++)
	{
		if(iter->second>1)
		{
			printf("%03d-%04d %d\n",iter->first/10000,iter->first%10000,iter->second);
			flag=0;
		}
	}
	if(flag)
	{
		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