zoukankan      html  css  js  c++  java
  • poj1002

    简单模拟

    View Code
    #include <iostream>
    #include <string>
    #include <algorithm>
    using namespace std;
    
    const    int        maxn = 100002;
    
    int        n;
    string    telephone[maxn];
    
    void make(string &a)
    {
        int        i;
    
        for (i = 0; i < a.length(); i++)
        {
            while (a[i] == '-' && i < a.length())
                a.erase(i, 1);
            if (i >= a.length())
                break;
            if (a[i] <= 'Z' && a[i] >= 'A')
            {
                if (a[i] == 'S')
                {
                    a[i] = '7';
                    continue;
                }
                if (a[i] == 'V')
                {
                    a[i] = '8';
                    continue;
                }
                if (a[i] == 'Y')
                {
                    a[i] = '9';
                    continue;
                }
                a[i] = (a[i] - 'A') / 3 + 2 + '0';
            }
        }
        a.insert(3, "-");
    }
    
    int main()
    {
        int        i, j;
        bool    did = false;
    
        //freopen("t.txt", "r", stdin);
        cin >> n;
        for (i = 0; i < n; i++)
        {
            cin >> telephone[i];
            make(telephone[i]);
        }
        sort(telephone, telephone + n);
        j = 1;
        for (i = 1; i < n; i++)
        {
            if (telephone[i] != telephone[i - 1])
            {
                if (j > 1)
                {
                    cout << telephone[i - 1] << " " << j << endl;        
                    did = true;
                }
                j = 1;
            }
            else
                j++;
        }
        if (j > 1)
        {
            cout << telephone[n - 1] << " " << j << endl;
            did = true;
        }
        if (!did)
            cout << "No duplicates." << endl;
        return 0;
    }
  • 相关阅读:
    价值观
    周记 改
    周记
    C语言问卷调查
    icon踩坑记录
    console.log(a)和console.log(window.a)的区别?
    记录一次微信二次分享的优化过程
    在jQuery中使用自定义属性
    10个JS技巧
    日常工作总结 2019/10/10
  • 原文地址:https://www.cnblogs.com/rainydays/p/2788495.html
Copyright © 2011-2022 走看看