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;
    }
  • 相关阅读:
    info plist各个功能的详解
    打个测试包弄成连接供别人下载测试
    封装的数据请求加上风火轮的效果
    福大软工 · BETA 版冲刺前准备(团队)
    福大软工 · 第十一次作业
    Alpha 冲刺 (10/10)
    Alpha 冲刺 (9/10)
    Alpha 冲刺 (8/10)
    Alpha 冲刺 (7/10)
    Alpha 冲刺 (6/10)
  • 原文地址:https://www.cnblogs.com/littlepage/p/12232889.html
Copyright © 2011-2022 走看看