• 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 } 
  • 相关阅读:
    LeetCode Array Easy 1. Two Sum
    关于VS2015 发布.net mvc 网站失败的问题
    2016计蒜之道复赛 百度地图的实时路况 floyd+cdq分治
    2016计蒜之道复赛 菜鸟物流的运输网络 网络流EK
    HDU5715 XOR 游戏 二分+字典树+dp
    HDU5697 刷题计划 dp+最小乘积生成树
    codeforces 687D Dividing Kingdom II 带权并查集(dsu)
    codeforces 687C
    codeforces 687B
    HDU 5693 D Game 区间dp
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/7229840.html
Copyright © 2020-2023  润新知