zoukankan      html  css  js  c++  java
  • Round #424 B. Keyboard Layouts

    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
     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <algorithm>
     5 
     6 using namespace std;
     7 char s1[30],s2[30];
     8 int mp[256];
     9 char str[1005];
    10 int main(){
    11     scanf("%s%s",s1,s2);
    12     int len=strlen(s1);
    13     for(int i=0;i<len;i++)
    14         mp[s1[i]]=i;       //¼Ç¼λÖÃÐÅÏ¢
    15     scanf("%s",str);
    16     len=strlen(str);
    17     for (int i=0;i<len;i++){
    18         if(str[i]>='A'&&str[i]<='Z')
    19             printf("%c",toupper(s2[mp[tolower(str[i])]]));
    20         else if(str[i]>='a'&&str[i]<='z')
    21             printf("%c",s2[mp[str[i] ] ]);
    22         else  printf("%c",str[i]);
    23     }
    24     printf("
    ");
    25     return 0;
    26 }
     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     map<char,char>mp;
     5     string s1,s2,c;
     6     cin>>s1>>s2>>c;
     7     for(int i=0;s2[i];i++)
     8         mp[s1[i]]=s2[i];
     9     for(int i=0;c[i];i++){
    10         char s;
    11         if(c[i]>='0'&&c[i]<='9')
    12             s=c[i];
    13         else if(c[i]>='a'&&c[i]<='z')
    14         s=mp[c[i]];
    15         else s=mp[c[i]+32]-32;
    16         cout<<s;
    17     }
    18     return 0;
    19 }
  • 相关阅读:
    学习完java基础,总结的一些东西,希望大佬们茶余饭后看看,如有错误还请指正
    JDK和JRE的简单概述
    堆排序
    mybatis的一级缓存
    重用执行器和批处理执行器
    JDBC statement和mybatis mapper statement
    深入浅出Mybatis技术原理与实战(杨开振)(带详细书签) PDF 下载 高清 完整版+源码
    mybatis执行器1
    mybatis执行器1---简单描述JDBC
    JDBC不再需要Class.forName()来显式加载jdbc驱动
  • 原文地址:https://www.cnblogs.com/z-712/p/7307947.html
Copyright © 2011-2022 走看看