Skip to content

Commit 22f968c

Browse files
committed
Add 06890.cpp
1 parent 6bb35cd commit 22f968c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

06xxx/06890.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
inline int c2i(char c) { return c - 'A'; }
6+
inline char i2c(int i) { return i + 'A'; }
7+
8+
inline char calc(char a, char b) {
9+
return i2c((c2i(a) + c2i(b)) % 26);
10+
}
11+
12+
void solve(void) {
13+
string a; getline(cin, a);
14+
string b; getline(cin, b);
15+
16+
for (int i=0; i<b.length(); i++) {
17+
if ('A' <= b[i] && b[i] <= 'Z') continue;
18+
b.erase(i--, 1);
19+
}
20+
21+
for (int i=0; i<b.length(); i++) {
22+
cout << calc(b[i], a[i % a.length()]);
23+
}
24+
}
25+
26+
int main(void) {
27+
ios::sync_with_stdio(false);
28+
cin.tie(nullptr);
29+
30+
solve();
31+
return 0;
32+
}

0 commit comments

Comments
 (0)