• Codeforces Round #424 B. Keyboard Layouts(字符串,匹配,map)


    
    
     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 char ch[3][30];
     5 char t[1005];
     6 
     7 int num[35];
     8 
     9 int main(){
    10     scanf("%s",ch[0]);
    11     scanf("%s",ch[1]);
    12     scanf("%s",t);
    13     
    14     for(int i=0;i<strlen(ch[0]);i++){
    15         num[ch[0][i]-'a']=i;
    16     }
    17     
    18     for(int i=0;i<strlen(t);i++){
    19         if(0<=t[i]-'0'&&t[i]-'0'<=9){
    20             printf("%c",t[i]);
    21         }else if('a'<=t[i]&&t[i]<='z'){
    22             printf("%c",ch[1][num[t[i]-'a']]);
    23         }else if('A'<=t[i]&&t[i]<='Z'){
    24             printf("%c",ch[1][num[t[i]-'A']]-32);
    25         }
    26         
    27         
    28         
    29     }
    30     printf("
    ");
    31     return 0;
    32 }
    
    
    
     1 #include <stdio.h>
     2 #include <string.h>
     3 char key[300];
     4 int main ()
     5 {
     6     char b,f[30],l[30],sent[10000];
     7     int i,j,x;
     8     scanf("%s",f);
     9     scanf("%s",l);
    10     scanf("%s",sent);
    11     for(i=0;i<26;i++)
    12     {
    13         key[f[i]]=l[i];
    14         key[f[i]-32]=l[i]-32;
    15     }
    16     for(i=0;i<strlen(sent);i++)
    17     {
    18         if(key[sent[i]])
    19             printf("%c",key[sent[i]]);
    20         else
    21         {
    22         
    23             printf("%c",sent[i]);
    24         }
    25     }
    26     return 0;
    27     
    28 }
     1 #include<stdio.h>
     2 
     3 int main()
     4 {
     5     char a[30],b[30],ch;
     6     int i=0;
     7     while((a[i]=getchar())!='
    ')    i++;
     8     i=0;
     9     while((b[i]=getchar())!='
    ')    i++;
    10     while((ch=getchar())!='
    ')
    11     {
    12         if(ch<65)    printf("%c",ch);
    13         else if(ch<97)
    14         {
    15             ch+=32;
    16             for(i=0;i<26;i++)
    17                 if(a[i]==ch)
    18                 {
    19                     printf("%c",b[i]-32);
    20                     break;
    21                 }
    22         }
    23         else
    24             for(i=0;i<26;i++)
    25                 if(a[i]==ch)
    26                 {
    27                     printf("%c",b[i]);
    28                     break;
    29                 }    
    30     }
    31     return 0;
    32 }
     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main()
     5 {
     6     char a[10000],c;
     7     int i;
     8     string s1,s2,s;
     9     cin>>s1>>s2>>s;
    10     for(i=0;i<26;++i)
    11         a[s1[i]]=s2[i];
    12     for(i=0;i<s.length();++i)
    13    {
    14        if(s[i]>=65&&s[i]<=90)
    15     {
    16         c=s[i]+32;
    17         s[i]=a[c]-32;
    18     }
    19     else if(s[i]>=97&&s[i]<=122)
    20         {
    21             s[i]=a[s[i]];
    22         }
    23    }
    24     cout<<s;
    25     return 0;
    26 }
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 using namespace std;
     5 
     6 char s1[33],s2[33],ch[222],s[1111];
     7 int len;
     8 
     9 int main()
    10 {
    11     scanf("%s%s%s",s1,s2,s);
    12     for(int i=0;i<=25;i++)
    13     {
    14         ch[s1[i]]=s2[i];
    15     }
    16     len=strlen(s);
    17     for(int i=0;i<len;i++)
    18     {
    19         if(s[i]>='A'&&s[i]<='Z')
    20         {
    21             s[i]+=32;
    22             s[i]=ch[s[i]]-32;
    23         }
    24         else if(s[i]>='a'&&s[i]<='z')
    25             s[i]=ch[s[i]];
    26         else
    27             s[i]=s[i];
    28     }
    29     printf("%s
    ",s);
    30     return 0;
    31 }
    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
  • 相关阅读:
    javascript的自定义对象
    解决trim兼容性
    AJAX
    javascript中的默认对象
    js原始数据类型
    javascript的内置对象
    空判断啊
    javascript的继承
    html如何设置P的高度为零?
    asp.net 生成静态页 自动分页
  • 原文地址:https://www.cnblogs.com/Roni-i/p/7171923.html
Copyright © 2020-2023  润新知