forked from ntalfer/codingame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathascii_art.cpp
47 lines (37 loc) · 887 Bytes
/
ascii_art.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
// Read inputs from stdin. Write outputs to stdout.
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ?";
vector<string> alpha_ascii;
int L, H;
string L_str, H_str, T;
getline(cin, L_str);
getline(cin, H_str);
getline(cin, T);
L = atoi(L_str.c_str());
H = atoi(H_str.c_str());
for (int i = 0; i < H; i++) {
string line;
getline(cin, line);
alpha_ascii.push_back(line);
}
vector<string> output(H, "");
for(int i=0; i<T.length(); i++) {
char s = toupper(T[i]);
if((s < 'A') or (s > 'Z'))
s = '?';
int index = alpha.find(s);
for(int j=0; j<H; j++) {
string s_line = alpha_ascii[j].substr(index*L, L);
output[j] += s_line;
}
}
for(int i=0; i<H; i++)
cout << output[i] << endl;
return 0;
}