C语言解法

P1914 小书童——凯撒密码

Coding_godnice20 @ 2020-01-24 15:24:26

#include<stdio.h>
#include<string.h>
int main()
{
    char str[500];//定义一个字符串存储原文字符串
    int n = 0;//定义一个int类型的变量存储n的值
    scanf_s("%d", &n);
    scanf_s("%s", &str,40);
    int length;//定义一个length表示原字符串的长度
    length = strlen(str);
    for (int i = 0; i < length; i++)
    {
        if ((str[i] + n) > 122)
        {
            str[i] = '`' + (str[i]+n) - 122;
        }
        else if ((str[i] + n) <= 122)
        {
            str[i] = str[i] + n;
        }
    }
    printf("%s", str);
}

by tangrunxi @ 2020-01-24 15:33:10

@Coding_godnice20 出门右转题解区提交,不谢


by CrTsIr400 @ 2020-01-24 15:35:32

@Coding_godnice20 出门右转题解区提交,不谢


by 1kri @ 2020-01-24 15:37:35

太强了%%%


by DeepSkyBlue__ @ 2020-01-24 15:42:38

这题还收题解吗qwq


by Zyque @ 2020-01-24 16:02:23


|