from "The Code Conversion Service": :-)
#include<iostream>
using namespace std;
string caesar( string message, int shift)
{
string result;
for (auto c : message)
{
if ( c >= 'a' && c <='z')
c = (c + shift - 'a') % ('z' - 'a' + 1) + 'a';
result += c;
}
return result;
}
int main()
{
string operation, message;
int shift;
cout << "Type 'decode', otherwise it will encode\n";
getline(cin,operation);
cout << "Type the message\n";
getline(cin, message);
cout << "Type the shift amount\n";
cin >> shift;
cout << caesar( message, (operation == "decode" ? - shift : shift));
}