You are viewing a single comment's thread. Return to all comments →
C++ solution:
string caesarCipher(string s, int k) { string alphabets = "abcdefghijklmnopqrstuvwxyz" ; for(int i=0;i<s.length();i++){ char c = tolower(s[i]); int pos = alphabets.find(c); if(pos == -1){ continue; } if(isupper(s[i])){ char newChar = alphabets[(pos+k)%26]; s[i] = toupper(newChar); }else{ s[i] = alphabets[(pos+k)%26]; }; } return s; }
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 →
C++ solution: