paulyang120 @ 2023-05-06 15:23:39
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
char a;
while(cin>>a)
{
if(a+n>122)
{
a=+n-25;
cout<<a;
continue;
}
a+=n;
cout<<a;
}
}
by OURUO @ 2023-05-06 15:29:10
string s;
int n,i,j;
cin>>n;
cin>>s;
for(i=0;i<s.size();++i)
{
for(j=1;j<=n;++j)
{
++s[i];
if(s[i]>'z')
s[i]='a';
}
}
cout<<s;
过程可以这样写。
by paulyang120 @ 2023-05-06 15:38:18
@OURUO 感谢
by www101 @ 2023-05-06 15:40:17
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
string a;
cin>>n;
cin>>a;
for(int i=0;i<a.size();i++){
if(a[i]+n>'z'){
printf("%c",a[i]+n-26);
}
else{
printf("%c",a[i]+n);
}
}
}
这样写
by OURUO @ 2023-05-12 15:32:21
@yangzhengxi 关注一下? : )想涨粉 : )
by Sqj147 @ 2023-06-16 22:13:52
a += (n - 26);