求大佬指点,只要60分

P1914 小书童——凯撒密码

ANNE2333 @ 2017-07-04 21:20:39

#include<iostream>
#include<cstring>
using namespace std;
char a[30];
int b;
int main(){    
    cin>>b>>a;
    int len=strlen(a)-1;    
    for(int i=0;i<=len;i++){
        a[i]=a[i]+b;
    }
    cout<<a;
    return 0;
}

by yzxbt @ 2017-07-09 17:21:53

@ ANNE2333

你忘了管'z'('z'下一个是'a')


by yzxbt @ 2017-07-09 17:28:12

万一n大于26呢?


by 798853158dfw @ 2017-07-21 16:55:45

将字符串分段,转ascll,加n,减‘a’的ascll,除以26,最后加‘a’的ascll,即可


|