zoukankan      html  css  js  c++  java
  • PAT Advanced 1084 Broken Keyboard (20分)

    On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.

    Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.

    Input Specification:

    Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or _ (representing the space). It is guaranteed that both strings are non-empty.

    Output Specification:

    For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.

    Sample Input:

    7_This_is_a_test
    _hs_s_a_es
    
     

    Sample Output:

    7TI

    坏键盘,乙级碰到过,我们在进行检测的时候

    读入串

    进行遍历第一个串,转大写后映射到map。

    进行遍历第二个串,进行映射到map为false。

    进行遍历第一个串,进行映射到map为false,并且打印。

    #include <iostream>
    #include <unordered_map>
    using namespace std;
    int main(){
        string str1, str2;
        unordered_map<char, bool> m;
        getline(cin, str1);
        getline(cin, str2);
        for(int i = 0; i < str1.length(); i++)
            m[toupper(str1[i])] = true;
        for(int i = 0; i < str2.length(); i++)
            m[toupper(str2[i])] = false;
        for(int i = 0; i < str1.length(); i++)
            if(m[toupper(str1[i])]) {
                cout << (char)toupper(str1[i]);
                m[toupper(str1[i])] = false;
            }
        system("pause");
        return 0;
    }
  • 相关阅读:
    杜教筛
    单纯形法
    回文树
    模板综合
    不明觉厉的数据结构题2
    gedit脚本
    01分数规划入门
    LCT裸题泛做
    洛谷P4586 [FJOI2015]最小覆盖双圆问题(最小圆覆盖)
    洛谷P1742 最小圆覆盖(计算几何)
  • 原文地址:https://www.cnblogs.com/littlepage/p/12232889.html
Copyright © 2011-2022 走看看