zoukankan      html  css  js  c++  java
  • 1033 旧键盘打字

    旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?

    输入格式:

    输入在 2 行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过 1 个字符的串。可用的字符包括字母 [a-zA-Z]、数字 0-9、以及下划线 _(代表空格)、,.-+(代表上档键)。题目保证第 2 行输入的文字串非空。

    注意:如果上档键坏掉了,那么大写的英文字母无法被打出。

    输出格式:

    在一行中输出能够被打出的结果文字。如果没有一个字符能被打出,则输出空行。

    输入样例:

    7+IE.
    7_This_is_a_test.

    输出样例:

    _hs_s_a_tst

    坏字符有空格,大小写不敏感

    #include <string>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    
    int main()
    {
        string u,uu,tu;
        getline(cin,uu);
        getline(cin,u);
        tu=uu;
        transform(uu.begin(), uu.end(), uu.begin(), ::tolower);
    
        int flag=0,k=1,ke=1;
        if((uu.find('+')!=uu.npos))flag=1;
        //if(uu.find(' ')!=uu.npos) ke=0;
        for(int i=0;i<u.length();i++)
        {
    
            if(!(flag&&'A'<=u[i]&&u[i]<='Z'))
            {
    //            if(u[i]=='_'&&ke)
    //            {
    //                k=0;
    //                cout<<u[i];
    //            }
    //            else
                if(uu.find(u[i])==uu.npos&&tu.find(u[i])==tu.npos)
                {
                    //cout<<(uu.find(u[i])==uu.npos)<<":"<<(tu.find(u[i])==tu.npos)<<":";
                    k=0;
                    cout<<u[i];
                    //cout<<endl;
                }
            }
        }
        if(k)
            cout<<"";
        return 0;
    }
  • 相关阅读:
    3-8
    3-7
    3-5
    3-4
    3-3
    3-2
    3-1
    2-11
    2-10
    2-9
  • 原文地址:https://www.cnblogs.com/chrysanthemum/p/13772030.html
Copyright © 2011-2022 走看看