c++60分,求助大佬

P1914 小书童——凯撒密码

wang0728 @ 2023-02-17 19:15:36

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

by yujinhao___ @ 2023-02-17 19:24:13

#include<iostream>
#include<string>
using namespace std;
int main()
{string a;
int n;
cin>>n;
cin>>a;
for(int i=0;i<a.length();i++)
{int x=a[i]+n%26;
if(x>'z')a[i]=x-26;
else a[i]=x;

}
cout<<a;
return 0;
}

by wang0728 @ 2023-03-04 15:46:45

@yujinhao___ 谢谢,最近没看洛谷


|