forked from Mohammed-Shoaib/Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE0033.cpp
More file actions
32 lines (28 loc) · 651 Bytes
/
E0033.cpp
File metadata and controls
32 lines (28 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Problem Code: TOTR
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
string touristTranslation(string S, unordered_map<char, char> &translation){
char c;
for(int i=0 ; i<S.length() ; i++){
c = S[i];
S[i] = translation[tolower(S[i])];
if(isupper(c))
S[i] = toupper(S[i]);
}
return S;
}
int main(){
int T;
string M, S;
unordered_map<char, char> translation({{'_', ' '}, {'.', '.'}, {',', ','}, {'!', '!'}, {'?', '?'}});
cin >> T >> M;
for(int i=0 ; i<M.length() ; i++)
translation['a' + i] = M[i];
while(T--){
cin >> S;
cout << touristTranslation(S, translation) << endl;
}
return 0;
}