poj 1002 487-3279(使用STL map)

//poj 1002 487-3279(使用STL map)
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<iostream>
#include<map>
using namespace std;
int ma[120];
void init()
{
    ma['-']=10;
    for(int i=0;i<3;i++)
    {
        ma['A'+i]=2;
        ma['D'+i]=3;
        ma['G'+i]=4;
        ma['J'+i]=5;
        ma['M'+i]=6;
        //ma['P'+i]=7;
        ma['T'+i]=8;
        ma['W'+i]=9;
    }
    ma['P']=ma['R']=ma['S']=7;
    for(int i=0;i<=9;i++)
    {
       ma[i+'0']=i;
    }
}
int main()
{
    map<string,int> mp;
    map<string,int>::iterator it;
    char str[100];
    string s;
    int a[8];
    char str1[9];
    int t;
    init();
    cin>>t;
    str1[3]='-';
    for(int di=0;di<t;di++)
    {
        scanf("%s",str);
        int len=0;
        int n=strlen(str);
        for(int i=0;i<n;i++)
        {
            if(ma[str[i]]!=10)
            {
                a[len++]=ma[str[i]];
                if(len==7) break;
            }
        }
        str1[0]=a[0]+'0';str1[1]=a[1]+'0';str1[2]=a[2]+'0';
        str1[4]=a[3]+'0';str1[5]=a[4]+'0';str1[6]=a[5]+'0';
        str1[7]=a[6]+'0';
        str1[8]='\0';
        s=str1;
        mp[s]++;
    }
    int flag=false;
    for(it=mp.begin();it!=mp.end();it++)
    {
        if((it->second)>1)
        {
           flag=true;
           cout<<it->first;
           printf(" %d\n",it->second);
        }
    }
    if(flag==false)
    {
        puts("No duplicates.");
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

u014068781

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值