题解 | 凯撒加密

凯撒加密

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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_STR_LEN 1001 
#define ALPHA_NUM 26

int main() {
    char s[MAX_STR_LEN] = {0};
    int move_time, i, my_str_len;

    scanf("%d", &move_time);
    scanf("\n");

    scanf("%s", s);

    move_time = move_time % ALPHA_NUM;

    my_str_len = strlen(s);

    for(i = 0; i < my_str_len; i++) {
        s[i] = (s[i] - 'a' + move_time) % ALPHA_NUM + 'a';
    }

    printf("%s", s);

    return 0;
}

全部评论

相关推荐

喜欢核冬天的哈基米很想上市:会爆NullPointerException的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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