求大佬解答,我自己运行挺正常啊

P1914 小书童——凯撒密码

pokemon_1 @ 2019-11-13 19:11:29

#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
void tran(char*,int);

int main(void)
{
    int n;
    char before[50];
    scanf("%d",&n);
    getchar();
    n%=26;
    fgets(before,50,stdin);
    tran(before,n);
    puts(before);

    return 0;
}

void tran(char* before,int n)
{
    char c;
    int n2;
    for(int i=0;i<strlen(before);i++)
    {
        c=*(before+i);
        if(n<='z'-c)
            *(before+i)=(char)(c+n);
        else
        {
            n2=n-('z'-c);
            *(before+i)=(char)('a'+n2-1);
        }
    }
}

|