zoukankan      html  css  js  c++  java
  • BUPT复试专题—密码(2009)

    题目描述

     

    输入

    有多组输入,每组:

    第一行:由26个小写字母组成的串以空格隔开,如 b a c e u f g h i j k l m n o p q r s t v w x y z d v y z r s q

    第二行:一个字符串(大写字母) 如: BUPTZ

    输出

    输出如上例(BUPTZ中  B用第一行的第二个字母替换,U用第21个替换,P用第('p'-'a'+1)个替换,Z用第26个字母q替换)

    样例输入

    b a c e u f g h i j k l m n o p q r s t v w x y z d v y z r s q
    BUPTZ
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    ABCD

    样例输出

    avptd
    abcd

    来源

    2009机考B题 

    #include<algorithm>
    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<map>
    using namespace std;
    
    int main()
    {
        char donser[100],temp[100],newone[100];
        map<char,int> chr;
        for(int i=1;i<=26;i++)
        {
            char x=i+'a'-1;
            chr.insert ( std::pair<char,int>(x,i) );
        }
        map<char,int>::iterator iter;
        /*map<char,int>::iterator iter;
            for(iter=chr.begin();iter!=chr.end();iter++)
                cout<<iter->first<<" "<<iter->second<<endl;*/
        while(gets(donser))
        {
            gets(temp);
            int y=0;
            for(int i=0;donser[i]!='';i++)
            {
                if(donser[i]!=' ')
                {
                    newone[y]=donser[i];
                    y++;
                }
            }
            newone[y]='';
            int j=0;
            while(temp[j]!='')
            {
                int num=chr[temp[j]+32];
                cout<<newone[num-1];
                j++;
            }
            cout<<endl;
            
        }
        return 0;
    }
  • 相关阅读:
    dedecms为导航栏目添加英文标题
    网页设计中一些小功能
    less使用总结
    canvas图形库
    前端面试总结三
    前端面试总结二
    DOM节点中获取文本易混淆的属性
    前端面试总结
    git 学习使用总结三(远程仓库操作)
    git 学习使用总结二(远程仓库操作)
  • 原文地址:https://www.cnblogs.com/dzzy/p/8608181.html
Copyright © 2011-2022 走看看