You are viewing a single comment's thread. Return to all comments →
using namespace std; int main() { string s; int cipher; cin >> cipher; cin >> s; cin >> cipher; for(char &c:s) { if(isalpha(c)){ char a = isupper(c)? 'A':'a'; c = a + (c - a + cipher) % 26; } } cout << s ; return 0; } `
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
include
using namespace std; int main() { string s; int cipher; cin >> cipher; cin >> s; cin >> cipher; for(char &c:s) { if(isalpha(c)){ char a = isupper(c)? 'A':'a'; c = a + (c - a + cipher) % 26; } } cout << s ; return 0; } `