c语言80分,大佬们求助!!

P1914 小书童——凯撒密码

CentViGa @ 2023-10-06 20:41:23

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

int main()
{
    int n,i;
    char a[51];
    scanf("%d",&n);
    scanf("%s",a);

    for( i=0;i < strlen(a); i++){
            if(a[i] + n < 'z'){

                a[i] += n;

            }
            if(a[i] + n > 'z'){

                a[i] = '`' +( n  -('z' - a[i] )); 

            }

            if(a[i] + n == 'z'){

                a[i] = 'z';

            }
    }

    printf("%s\n",a);
    return 0;
}

|