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

用mapG++过不了会T,C++能过

Posted by 3016216115 at 2018-03-22 21:57:54 on Problem 1002
#include<iostream>
#include<map>
#include<string>
#include<stdio.h>
using namespace std;

int main()
{
	map<string,int>resultmap;
	int n;
	char num[] = "22233344455566670778889990";
	string s;
	string s1;
    scanf("%d",&n);
	while(n>0)
	{
		cin >> s;
		int len = s.length();
		int j = 0;
		s1.clear();
		for(int i = 0; i<len;i++)
		{
			if(s[i] == '-')
			{
				continue;
			}
			else if(isdigit(s[i]))
			{
				s1 +=s[i];
			}
			else
			{
				s1+=num[s[i]-'A'];
			}
			
		 }
		 s1.insert(3,1,'-');
		 resultmap[s1]++;
		 n--; 
	}
		 bool flag = false;
		 for(map<string,int>::const_iterator i = resultmap.begin();i != resultmap.end();i++)
		 {
		 	if(i->second > 1)
		 	{
		 		string s2 = i->first;
		 		int nnn = i->second;
		 		printf("%s %d\n",s2.c_str(),nnn);
		 		flag = true;
			 }
		 }
		 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