有没有大佬看看我这题哪错了,包回关的

P1914 小书童——凯撒密码

sweet_520 @ 2024-10-25 22:02:28

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] + n > 'z')
        {
            char temp = s[i];
            s[i] = 'a';

            s[i] += n - ('z' - temp);
        }
        else
        s[i] += n;//s本身已经为string,无需强制转换

    }
    cout << s << endl;
}

by 潘德理2010 @ 2024-10-25 22:12:52

            s[i] += n - ('z' - temp);

改成

            s[i] += n - ('z' - temp)-1;

by lyh123123 @ 2024-11-20 18:42:17

你的--------return 0 呢


|