C语言 求救!!!

P1914 小书童——凯撒密码

nick360 @ 2024-08-25 16:18:03

有一个点WA了,未知原因。下载数也用完了

#include<stdio.h>

int main(void){
    int n,i=0;
    char ch,str[51];
    scanf("%d",&n);
    scanf("%s",str);
    while(str[i]>='a'&&str[i]<='z'){
        str[i]+=(n%26);
        if(str[i]>'z') str[i]-=26;
        printf("%c",str[i]);
        i++;
    }
    return 0;
}

by jzm0708 @ 2024-08-25 17:00:28

@nick360

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
string s;
int main(){

    cin>>n>>s;
    for(int i=0;i<=s.size()-1;++i){
        for(int j=1;j<=n;++j){
            ++s[i];
            if(s[i]>'z')
            s[i]='a';
        }
    }
    cout<<s;

    return 0;
}

求关


|