487-3279

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int num;
    map<string, int>::iterator  iter; 
    int a[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0}; 
    cin>>num;
    string temp;
    map<string,int> mymap; 
    int sum;
    for(int i=0;i<num;i++)
    {
        cin>>temp;
        sum=0;
        for(int j=0;j<temp.length();j++)
        {
            if(temp[j]=='-')
            continue;
            else
            {
                if(temp[j]>='0'&&temp[j]<='9')
                sum=sum*10+temp[j]-'0';
                else
                sum=sum*10+a[temp[j]-'A'];
            }
        }
        int k=0;
        string temp1="";
        int shang;
        int yushu;
        while(k<7)
        {
        //shang=sum/int(pow(10,6-k));
        //yushu=sum%int(pow(10,6-k));
        int h=1;
        for(int w=0;w<6-k;w++)
        h=h*10;
        shang=sum/h;
        yushu=sum%h;
        sum=yushu;
        temp1+='0'+shang;
        if(k==2)
        temp1+='-';    
        k++;
        }
        mymap[temp1]++;            
    } 
     
    int flag=0;
    for(iter = mymap.begin(); iter != mymap.end(); iter++)  
    {
        if(iter->second>1)
        {
            flag=1;
        cout<<iter->first<<" "<<iter->second<<endl;
        }
    }
    if(flag==0)
    cout<<"No duplicates."<<endl;
    return 0;
}

中间部分有两种方式,VC推荐pow,刷题网站用比较low的。

原文地址:https://www.cnblogs.com/xlqtlhx/p/6081438.html