求助!#4没过,后三个无法输出;测试数据为25 abcxyz

P1914 小书童——凯撒密码

2022111470yr @ 2022-10-28 19:25:26

#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char ch[50] = "\0";
    scanf("%s",ch);
    n = n%26;
    for(int i = 0;i<50;i++){
        ch[i] = ch[i]+n;
        if(ch[i]>'z'){
            ch[i] = ch[i] - 'z' + 'a'-1;
        }
        if(ch[i]>='a'&&ch[i]<='z'){
            printf("%c",ch[i]);
    }}
    return 0;
    }

by _TeaClaudz_ @ 2022-11-11 21:37:36

@2022111470yr 我的#4也没过

亲,这边建议您使用strlen()或者string::length()呢!


|