-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathE_Keyboard.cpp
37 lines (32 loc) · 869 Bytes
/
E_Keyboard.cpp
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
33
34
35
36
37
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string s1 = "qwertyuiop", s2 = "asdfghjkl;", s3 = "zxcvbnm,./";
void printStringByMatch(int index, string input, char direction) {
if(index == -1) {
return;
}
if(direction == 'R') {
cout << input[index - 1];
} else {
cout << input[index + 1];
}
}
int main() {
char direction;
cin >> direction;
string input;
cin >> input;
int size = input.size();
for (int i = 0; i < size; i++)
{
vector<int> match;
int charIdxIn1 = s1.find(input[i]);
int charIdxIn2 = s2.find(input[i]);
int charIdxIn3 = s3.find(input[i]);
printStringByMatch(charIdxIn1, s1, direction);
printStringByMatch(charIdxIn2, s2, direction);
printStringByMatch(charIdxIn3, s3, direction);
}
}