qiangzian @ 2022-11-19 22:52:19
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,l;
string s;
int main(){
cin>>n;
cin>>s;
l=s.size() ;
for(int i=0;i<l;i++)
{
if(s[i]+n>122)
s[i]=96+(n%25);
else
s[i]+=n;
cout<<s[i];
}
return 0;
}
by ____someone____ @ 2022-11-19 23:05:15
@qiangzian 循环里第一个判断改一下就行了
#include<bits/stdc++.h>
using namespace std;
int n,a,l;
string s;
int main()
{
cin>>n;
cin>>s;
l=s.size() ;
for(int i=0;i<l;i++)
{
if(s[i]+n>122)
s[i]=s[i]+n-26;
else
s[i]+=n;
cout<<s[i];
}
return 0;
}
by qiangzian @ 2022-11-27 11:37:54
@someone 谢谢,谢谢!