[CLOSED] Why am I getting this result?! Please help!
#include <iostream> #include <string> using namespace std; int main() { string userstr; cin >> userstr; cout << userstr << endl; char group[] = {'a', 'b', 'c', 'd','e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p','q', 'r', 's', 't', 'u', 'v','w', 'x', 'y', 'z', 'a', 'b', 'c', 'd','e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p','q', 'r', 's', 't', 'u', 'v','w', 'x', 'y', 'z'}; for(int n = 0; n < userstr.length(); n++) { for(int l = 26; l < 52; l++) { if(userstr[n] == group[l]) { userstr[n] = group[l - 1]; } }; }; cout << userstr; return 0; } If I input 'a' it gives me 'y' (when it should be giving 'z')! With all others it works fine, just not 'a'. Ex. Input: c Output: b