求助,怎么全部WA

P1914 小书童——凯撒密码

郭亮20510507027 @ 2022-03-09 09:05:12

#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,j,len;
    scanf("%d",&n);
    char pass[50];
    getchar();
    gets(pass);
    len=strlen(pass);
    for(i=0;i<len;i++)
    {
        if(pass[i]=='z')
            pass[i]=pass[i]-26+n;
        else
            pass[i]=pass[i]+n;
    }
    puts(pass);
    return 0;
}

by Jasper08 @ 2022-03-09 10:30:37

@郭亮20510507027


#include <iostream>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    string str;
    cin >> str;
    for (int i = 0; i < str.size(); ++i)
    {
        str[i] = ((int)(str[i]) - 'a' + n) % 26 + 'a';
        cout << str[i];
    }
    return 0;
}
···

|