这么简单却AC不了,实在不理解,求解

P1914 小书童——凯撒密码

cilinya @ 2020-10-09 11:00:23

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    char a[51];
    cin>>n;
    cin>>a;
    for(int i=0;i<strlen(a);i++){
    if(a[i]>='a'&&a[i]<'z'){
        a[i]+=n;
    }else if(a[i]=='z'){
        a[i]='a'+n-1;
    }
        }
        cout<<a;    
    return 0;
}

by Sktain @ 2020-10-09 11:03:52

你没判断是否超过'z'


by Reobrok_Kk @ 2020-10-09 11:18:56

谢谢提供水题


by 小仓朝阳 @ 2020-10-09 13:02:13

兄弟你看不起红题?


by cilinya @ 2020-10-10 17:27:04

@Sktain 感谢提醒哦


|