Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string encrypt(const string& s, int n) {
- int real_shift = n % 26;
- string new_string = "";
- for (int i = 0; i < s.length(); i++) {
- if (s[i] != ' ') {
- if (s[i] + real_shift > 'z') {
- new_string += s[i] + real_shift - 'z' + 96;
- }
- else {
- new_string += s[i] + real_shift;
- }
- }
- else {
- new_string += ' ';
- }
- }
- return new_string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement