题解 | 凯撒加密

凯撒加密

https://www.nowcoder.com/practice/006b7917d3784371a43cfbae01a9313d

#include <iostream>
using namespace std;
#include <string>

char letter[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z'};

int main() {    
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++)
    {
        s[i] = letter[(s[i]-'a'+n)%26];
    }
    cout << s;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务