-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC++.cpp
47 lines (42 loc) · 858 Bytes
/
C++.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
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
using namespace std;
vector<string> split(const string &str, char delimiter)
{
vector<string> tokens;
stringstream ss(str);
string token;
while (getline(ss, token, delimiter))
{
tokens.push_back(token);
}
return tokens;
}
int main()
{
int rows;
cin >> rows;
cin.ignore();
map<char, string> alphabets;
string output = "";
for (int i = 0; i < rows; i++)
{
string row;
getline(cin, row);
vector<string> splitedRow = split(row, ' ');
for (int j = 0; j < splitedRow.size(); j++)
{
alphabets[splitedRow[j][0]] = to_string(i) + to_string(j);
}
}
string message;
getline(cin, message);
for (int i = 0; i < message.length(); i++)
{
output += alphabets[message[i]];
}
cout << output << endl;
}