3,4不通过,哪位大佬能帮忙看看有什么问题吗?

P1914 小书童——凯撒密码

qinlei @ 2022-03-17 23:45:20

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

char a[105];
int main()
{
    int n;
    scanf("%d", &n);
    scanf("%s", a);
    for (unsigned int i = 0; i < strlen(a); i++)
    {
        a[i] = a[i] + n;
        while (a[i] > 'z')
            a[i] = a[i] - 26;
        printf("%c", a[i]);
    }
    return 0;
}

by GaoKui @ 2022-03-18 00:25:20

字符型最大能存的数值貌似是127来着,加上n以后溢出了吧


by GaoKui @ 2022-03-18 00:29:54

我第一次提交的时候也是这么被坑的


|