• poj.org --map-- 1002


    #include <iostream>
    #include <map>
    #include <string>
    #include <cstring>
    #include <cstdio>
    using namespace std;
    map<string,int> my;
    char a[30]="2223334445556667777888999";
    int main(int argc, char *argv[])
    {
        int n,i,j,sum; char ss[1005],s[1005];
        while(scanf("%d",&n)!=EOF)
        {   
            my.clear(); sum=0;
            while(n--)
            {
                scanf("%s",ss);
                for(j=i=0;i<strlen(ss);i++)
                {
                    if(j==3)  s[j++]='-';
                    if(ss[i]>='A'&&ss[i]<='Z')  s[j++]=a[ss[i]-'A'];
                    else if(ss[i]!='-') s[j++]=ss[i];
                }
                s[j]=0;
                my[s]++;
            }
            map<string,int> ::iterator it;
            for(it=my.begin();it!=my.end();it++)
            {
                if((*it).second>1) {cout<<(*it).first; printf(" %d
    ",(*it).second); sum++;}
            }
            if(!sum) printf("No duplicates.
    ");
        }
        return 0;
    }
    View Code
    #include <iostream>
    #include <map>
    #include <string>
    #include <cstring>
    #include <cstdio>
    using namespace std;
    map<string,int> my;
    char a[30]="2223334445556667777888999";
    int main(int argc, char *argv[])
    {
    	int n,i,j,sum; char ss[1005],s[1005];
    	while(scanf("%d",&n)!=EOF)
    	{   
    		my.clear(); sum=0;
    		while(n--)
    		{
    			scanf("%s",ss);
    			for(j=i=0;i<strlen(ss);i++)
    			{
    				if(j==3)  s[j++]='-';
    				if(ss[i]>='A'&&ss[i]<='Z')  s[j++]=a[ss[i]-'A'];
    				else if(ss[i]!='-') s[j++]=ss[i];
    			}
    			s[j]=0;
    			my[s]++;
    		}
    		map<string,int> ::iterator it;
    		for(it=my.begin();it!=my.end();it++)
    		{
    			if((*it).second>1) {cout<<(*it).first; printf(" %d
    ",(*it).second); sum++;}
    		}
    		if(!sum) printf("No duplicates.
    ");
    	}
    	return 0;
    }
  • 相关阅读:
    [译]ABP vNext微服务演示,项目状态和路线图
    [译]初试C# 8.0
    [译]ABP vNext介绍
    ViewModel从未如此清爽
    python 函数基础及装饰器
    python 基础一
    scrapy基础二
    scrapy 基础
    python 基础技巧
    pandas 基础
  • 原文地址:https://www.cnblogs.com/2014acm/p/3891227.html
Copyright © 2020-2023  润新知