-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathROT13WithString.cpp
More file actions
56 lines (48 loc) · 1.38 KB
/
ROT13WithString.cpp
File metadata and controls
56 lines (48 loc) · 1.38 KB
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
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string>
using namespace std;
string rot13(const string& str) {
string result;
for (char c : str) {
if (isalpha(c)) {
if (isupper(c)) {
result += (c - 'A' + 13) % 26 + 'A';
}
else {
result += (c - 'a' + 13) % 26 + 'a';
}
}
else {
result += c;
}
}
return result;
}
int main()
{
cout << rot13("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop!@#$%^&*-+=?,qrstuvwxyz8231564970");
return 0;
}
/*Description:
How can you tell an extrovert from an introvert at NSA?
Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf.
I found this joke on USENET, but the punchline is scrambled. Maybe you can decipher it?
According to Wikipedia, ROT13 is frequently used to obfuscate jokes on USENET.
For this task you're only supposed to substitute characters. Not spaces, punctuation, numbers, etc.
Test examples:
"EBG13 rknzcyr." -> "ROT13 example."
"This is my first ROT13 excercise!" -> "Guvf vf zl svefg EBG13 rkprepvfr!"
Strings
Ciphers
Regular Expressions
Algorithms*/
// /> フ
// | n n 彡
// /`ミ_xノ
// / |
// / ヽ ノ
// │ | | |
// / ̄| | | |
// | ( ̄ヽ__ヽ_)__)
// \二つ
// ITS CAT FOR YOU