对于这种会变成环状的,一般可以考虑取模

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    string a;
    getline(cin, a);
    for (int i = 0; i < a.size(); ++i)
    {
        if  (a[i] >= 'A' && a[i] <= 'Z') //是大写字母
            a[i] = (a[i] - 'A' + 1) % 26 + 'A';
        else if (a[i] >= 'a' && a[i] <= 'z')
            a[i] = (a[i] - 'a' + 1) % 26 + 'a';
    }
    cout << a << endl;
    return 0;
}