1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
#include <iostream> using namespace std; char askSentence (){ int c; cout << "Sentence: "; do{ c = getchar(); }while(getchar() != '\n'); return c; } int displacement (){ int displ; cout << "The displacement: "; cin >> displ; return displ; } char modify(char &letter, int disp){ char x; do{ if(letter <= 'z' && letter >= 'a'){ x = letter + desp; }else if (letter <= 'Z' && letter >= 'A'){ x = letter + desp; }else if (letter > 'Z'){ x = letter - 'Z' + 'A' - 1; }else if (letter > 'z'){ x = letter - 'z' + 'a' - 1; } }while(letter != '\n'); return x; } int main(){ int disp = displacement(); char s = askSentence(); cout << modify(s, disp); return 0; }