831B - Keyboard Layouts - CodeForces Solution


implementation strings *800

Please click on ads to support us..

Python Code:

s1=input()
s1=s1.lower()
s2=input()
s2=s2.lower()
dic ={}
for i in range(len(s1)):
    dic[s1[i]]=s2[i]
s3=input()
for i in range(len(s3)):
    if s3[i].islower():
        print(dic[s3[i]], end="")
    elif s3[i].isupper():
        string2=s3[i]
        string2=string2.lower()
        string= dic[string2]
        print(string.upper(), end="")
    else:
        print(s3[i], end="")
        
        
        

C++ Code:

#include<bits/stdc++.h>
using namespace std;
string firstlayout,secondlayout,typedinthefirstlayout;
map<char,char> mp;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> firstlayout >> secondlayout >> typedinthefirstlayout;
    for(int i=0;i<26;i++)
    {
        mp[firstlayout[i]]=secondlayout[i];
        mp[firstlayout[i]-32]=secondlayout[i]-32;
    }
    for(int i=0;i<typedinthefirstlayout.size();i++)
    {
        if(typedinthefirstlayout[i]>='0' && typedinthefirstlayout[i]<='9')
            cout << typedinthefirstlayout[i];
        else cout << mp[typedinthefirstlayout[i]];
    }
}


Comments

Submit
0 Comments
More Questions

264A - Escape from Stones
1506A - Strange Table
456A - Laptops
855B - Marvolo Gaunt's Ring
1454A - Special Permutation
1359A - Berland Poker
459A - Pashmak and Garden
1327B - Princesses and Princes
1450F - The Struggling Contestant
1399B - Gifts Fixing
1138A - Sushi for Two
982C - Cut 'em all
931A - Friends Meeting
1594A - Consecutive Sum Riddle
1466A - Bovine Dilemma
454A - Little Pony and Crystal Mine
2A - Winner
1622B - Berland Music
1139B - Chocolates
1371A - Magical Sticks
1253A - Single Push
706B - Interesting drink
1265A - Beautiful String
214A - System of Equations
287A - IQ Test
1108A - Two distinct points
1064A - Make a triangle
1245C - Constanze's Machine
1005A - Tanya and Stairways
1663F - In Every Generation