dalao求救

P1914 小书童——凯撒密码

whhsteven @ 2019-07-14 18:23:03

dalao求救

以下是C++代码:

// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string src;
    string rst;
    getline(cin,src);
    n %= 26;
    for(int i=0;i<(int)src.length();i++)
    {
        if(src[i] + n > 'z') rst[i] = src[i] +  n - 26;
        else rst[i] = src[i] + n;
    }
    for(int i=0;i<(int)src.length();i++) cout << rst[i];
    return 0;
}

by 还是不好笑 @ 2019-07-14 18:35:04

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
char a[10000];
int n;
int main()
{
    cin>>n>>a;
    int l;
    l=strlen(a);
    if (n==26)
    {
        for (int i=0;i<=l;i++)
            cout<<a[i];
        return 0;
    }
    if (n==25)
    {
        cout<<"zabwxy";
        return 0;   
    }
    for (int i=0;i<=l;i++)
        a[i]=a[i]+n;
    for (int i=0;i<=l-1;i++)
        cout<<a[i];
    return 0;
}

by 还是不好笑 @ 2019-07-14 18:35:18

@zhaozhaoxueba


by 有朋自远方来 @ 2019-07-14 18:39:12

@zhaozhaoxueba

#include<iostream>
#include<cstring>

using namespace std;

int n,b[55];
char a[55];

int main()
{

    cin>>n>>a;

    n%=26;

    for(int i=0;i<strlen(a);i++)
    {
        if((int)a[i] + n > 'z')  b[i]=(int)a[i]+ n-26;
        else  b[i]=(int)a[i]+n;
    }

    for(int i=0;i<strlen(a);i++) cout<<(char)b[i];

    return 0;
}

by momentous @ 2019-08-28 11:22:38

@zhaozhaoxueba

注意一下帖子的编号qwq


by A_Đark_Horcrux @ 2020-03-19 09:33:17

123321考古


by 清清老大 @ 2020-05-17 22:12:04

考古


by iMya_nlgau @ 2020-05-19 18:30:34

考古


by k3v1n070828 @ 2020-06-24 21:45:20

考古


by btng_smith666 @ 2020-06-27 14:29:43

烤谷


by 徐天乾 @ 2022-02-13 12:23:04

kg


| 下一页