zoukankan      html  css  js  c++  java
  • CF-831B

    B. Keyboard Layouts
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.

    You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts in the same order.

    You are also given some text consisting of small and capital English letters and digits. It is known that it was typed in the first layout, but the writer intended to type it in the second layout. Print the text if the same keys were pressed in the second layout.

    Since all keys but letters are the same in both layouts, the capitalization of the letters should remain the same, as well as all other characters.

    Input

    The first line contains a string of length 26 consisting of distinct lowercase English letters. This is the first layout.

    The second line contains a string of length 26 consisting of distinct lowercase English letters. This is the second layout.

    The third line contains a non-empty string s consisting of lowercase and uppercase English letters and digits. This is the text typed in the first layout. The length of s does not exceed 1000.

    Output

    Print the text if the same keys were pressed in the second layout.

    Examples
    input
    qwertyuiopasdfghjklzxcvbnm
    veamhjsgqocnrbfxdtwkylupzi
    TwccpQZAvb2017
    output
    HelloVKCup2017
    input
    mnbvcxzlkjhgfdsapoiuytrewq
    asdfghjklqwertyuiopzxcvbnm
    7abaCABAABAcaba7
    output
    7uduGUDUUDUgudu7

    题意:

    输出用a敲出c的顺序敲b会产生的字符串

    注意大小写转换

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main(){
     5     char s1[128],s2[128],s3[1010];
     6     cin>>s1>>s2>>s3;
     7     char s4[128];
     8     for(int i=0;i<26;i++){
     9         s4[s1[i]]=s2[i];
    10     }
    11 //    cout<<s4['t']<<endl;
    12     int len=strlen(s3);
    13     for(int i=0;i<len;i++){
    14         if(s3[i]>='a'&&s3[i]<='z'){
    15             s3[i]=s4[s3[i]];
    16         }
    17         else if(s3[i]>='A'&&s3[i]<='Z'){
    18             s3[i]=s4[s3[i]-'A'+'a']-'a'+'A';
    19         }
    20     }
    21     cout<<s3<<endl;
    22     return 0;
    23 } 
  • 相关阅读:
    修改服务器时间及时区
    风情万种awk
    追忆似水流年sed
    lvm笔记
    正则不怎么会用
    在CentOS7.5的虚拟环境下新建你的django项目
    Django学习过程中的排错总结
    我一直记不住的vim用法
    关于自建yum源拾遗
    Djangp2.x版本报错找不到模版目录下的文件
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/7229840.html
Copyright © 2011-2022 走看看