Tourist Translations - TOTR Code Chef Easy Question

Hello Everyone , today we will be discussing the question Tourist Translations code named TOTR .
Here is the link to the PROBLEM

So , this is a straightforward question . Its just a code question .
So just create a dictionary map of the ByteLandian Language and English Language .

Next , just use the dictionary and translate .

Here is the straightforward C++ code for it . Please understand it and leave your doubts in the comments section .

Here is the Code :-


#include <iostream>
#include <vector>
using namespace std;

int main() {
    int t;
    scanf("%d",&t);
    string key;
    cin>>key;
    while(t--)
    {
        string s;
        cin>>s;
        int i=0;
        while(s[i]!='\0')
        {
            if('a'<=s[i] && s[i]<='z')
            {
                cout<<key[s[i]-97];
            }
            else if(s[i]=='_')
            {
                cout<<" ";
            }
            else if(s[i]>='A' && s[i]<='Z')
            {
                cout<<(char)((key[s[i]-65])-32);
            }
            else
            {
                cout<<s[i];
            }
            i++;
        }
        cout<<endl;
       
    }
// your code goes here
return 0;
}

Comments

Popular Posts