80分求助

P1914 小书童——凯撒密码

ylzxbcyy @ 2023-10-29 21:45:22

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

int main()
{string s;
int a;
cin>>a;
cin>>s;
for(int i=0;i<s.length();i++)
{
if((s[i]+a)>'z')
{s[i]=((s[i]+a-'z')%26+'a'-1);}
else {
s[i]=s[i]+a;}
}
    cout<<s;
}

by 3DE3 @ 2023-11-02 10:56:48

同问


|