2023-10-24 13:14:21 +02:00
|
|
|
#include <iostream>
|
2023-10-24 21:38:29 +02:00
|
|
|
#include <cctype>
|
2023-10-24 13:14:21 +02:00
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
char* text;
|
|
|
|
int key;
|
|
|
|
if(argc < 3)
|
|
|
|
{
|
|
|
|
std::cout << "Usage: " << argv[0] << " <plain text> <key>" << std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
text = argv[1];
|
|
|
|
key = atoi(argv[2]);
|
|
|
|
|
|
|
|
for(int i = 0; text[i] != 0; ++i)
|
|
|
|
{
|
2023-10-25 12:29:28 +02:00
|
|
|
if(text[i] == ' ')
|
|
|
|
{
|
|
|
|
std::cout << ' ';
|
|
|
|
continue;
|
|
|
|
}
|
2023-10-24 21:38:29 +02:00
|
|
|
char c = std::tolower(text[i])+key;
|
2023-10-24 13:14:21 +02:00
|
|
|
if(c < 'a') c+=26;
|
|
|
|
if(c > 'z') c-=26;
|
|
|
|
std::cout << c;
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|