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 } 
  • 相关阅读:
    vscode快捷键的中文版
    小程序css--view标签下英文不换行,中文会自动换行
    微信小程序设置背景铺满全屏
    MAC系统上不能调试华为手机
    js 空函数的作用
    五子棋 AI(AIpha-beta算法)
    ( function(){…} )()和( function (){…} () )是两种立即执行函数
    vscode快捷键
    20192328牛梓萌第一周作业
    第一次作业
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/7229840.html
Copyright © 2011-2022 走看看