-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (26 loc) · 622 Bytes
/
main.cpp
File metadata and controls
32 lines (26 loc) · 622 Bytes
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
#include <iostream>
#include <string>
#include <string_view>
#include <ranges>
[[nodiscard]]
std::string
rot47(std::string_view input)
{
auto transform = [](char c) { return (c >= 33 && c <= 126) ? static_cast<char>(33 + ((c - 33 + 47) % 94)) : c; };
std::string output;
output.reserve(input.size());
for (char c : input | std::views::transform(transform)) {
output.push_back(c);
}
return output;
}
int
main(int argc, char* argv[])
{
for (int i = 1; i < argc; ++i) {
std::cout << rot47(argv[i]);
if (i + 1 < argc) {
std::cout << ' ';
}
}
}