baidu_27549073 2017-08-22 02:20 采纳率: 50%
浏览 890
已结题

ACM编译失败,是不能使用map吗,本地是对的

http://poj.org/problem?id=1002

#include <map>
#include <iostream>
using namespace std;
map<const char, int> phonemap = {
                                    { 'A', 2 },
                                    { 'B', 2 },
                                    { 'C', 2 },
                                    { 'D', 3 },
                                    { 'E', 3 },
                                    { 'F', 3 },
                                    { 'G', 4 },
                                    { 'H', 4 },
                                    { 'I', 4 },
                                    { 'J', 5 },
                                    { 'K', 5 },
                                    { 'L', 5 },
                                    { 'M', 6 },
                                    { 'N', 6 },
                                    { 'O', 6 },
                                    { 'P', 7 },
                                    { 'R', 7 },
                                    { 'S', 7 },
                                    { 'T', 8 },
                                    { 'U', 8 },
                                    { 'V', 8 },
                                    { 'W', 9 },
                                    { 'X', 9 },
                                    { 'Y', 9 } 
                                };
int main()
{
    int num;
    cin >> num;
    //int phone[7 * num];
    map<int, int> phones;
    for (int i = 0; i < num; i++)
    {
        int *phone = new int[7];
        int curPhoneIndex = 0;
        char inputphone[16];
        cin >> inputphone;
        for (int i = 0; i < 16; i++)
        {
            if (inputphone[i] > 47 && inputphone[i] < 59)
            {
                phone[curPhoneIndex] = inputphone[i] - 48;
                curPhoneIndex++;
            }
            else if (phonemap[inputphone[i]] == NULL)
            {

            }
            else
            {
                phone[curPhoneIndex] = phonemap[inputphone[i]];
                curPhoneIndex++;
            }
        }
        int phonenumber = phone[0] * 1000000 + phone[1] * 100000 + phone[2] * 10000 + phone[3] * 1000 + phone[4] * 100 + phone[5] * 10 + phone[6];
        if (phones.find(phonenumber) == phones.end())
        {
            phones.insert(map<int,int>::value_type(phonenumber, 1));
        }
        else
        {
            phones[phonenumber] += 1;
        }
    }
    map<int,int>::iterator it = phones.begin();
    bool has_count_2 = false;
    for (; it != phones.end(); it++)
    {
        if (it->second < 2)
        {
            continue;
        }
        int i = 0;
        cout << it->first / 1000000;
        cout << it->first % 1000000 / 100000;
        cout << it->first % 100000 / 10000;
        cout << "-";
        cout << it->first % 10000 / 1000;
        cout << it->first % 1000 / 100;
        cout << it->first % 100 / 10;
        cout << it->first % 10;
        cout << " " << it->second << endl;
        has_count_2 = true;
    }
    if (!has_count_2)
    {
        cout << "No duplicates."<< endl;
    }
    return 0;
}


  • 写回答

2条回答 默认 最新

  • T_world 2017-08-22 02:53
    关注

    OJ给出的报错信息是什么呢

    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能