# 为什么只有60啊(p1914)。

P1914 小书童——凯撒密码

Tang7 @ 2024-11-08 11:27:48

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n;
    cin>>n>>s;
    for(int i=0;i<s.size();i++)
    {
        s[i]+=n;
        if(s[i]>122)
        s[i]-=26;
    }
    cout<<s;
    return 0;
}

by SunXiaolang @ 2024-11-08 12:12:56

@Tang7 你有没有判断如果是z呢


by SunXiaolang @ 2024-11-08 12:13:35

@Tang7 ```cpp

include<bits/stdc++.h>

using namespace std;

int main(){ int n,i,b; string a; cin>>n>>a; b=a.length(); for (i=0;i<b;i++){ for (int l=0;l<n;l++){ a[i]++; if (a[i]>'z') a[i]='a'; } } cout<<a; }


by SunXiaolang @ 2024-11-08 12:14:00

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,i,b;
    string a;
    cin>>n>>a;
    b=a.length();
    for (i=0;i<b;i++){
        for (int l=0;l<n;l++){
            a[i]++;
            if (a[i]>'z') a[i]='a';
        } 
    }
    cout<<a;
}

@Tang7 求关


|